{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 工具导入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "from scipy import stats\n",
    "\n",
    "import gc\n",
    "from collections import Counter\n",
    "import copy\n",
    "\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    " \n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据读取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#读取数据集\n",
    "\n",
    "#test_data = pd.read_csv('./data_format1/test_format1.csv')\n",
    "#train_data = pd.read_csv('./data_format1/train_format1.csv')\n",
    "\n",
    "#user_info = pd.read_csv('./data_format1/user_info_format1.csv')\n",
    "#user_log = pd.read_csv('./data_format1/user_log_format1.csv')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据资源查看"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#train_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#test_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "#user_info.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#user_log.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据读取函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_csv(file_name, num_rows):\n",
    "    return pd.read_csv(file_name, nrows=num_rows)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 内存压缩方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [],
   "source": [
    "# reduce memory\n",
    "def reduce_mem_usage(df, verbose=True):\n",
    "    start_mem = df.memory_usage().sum() / 1024**2\n",
    "    numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n",
    "\n",
    "    for col in df.columns:\n",
    "        col_type = df[col].dtypes\n",
    "        if col_type in numerics:\n",
    "            c_min = df[col].min()\n",
    "            c_max = df[col].max()\n",
    "            if str(col_type)[:3] == 'int':\n",
    "                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:\n",
    "                    df[col] = df[col].astype(np.int8)\n",
    "                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:\n",
    "                    df[col] = df[col].astype(np.int16)\n",
    "                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:\n",
    "                    df[col] = df[col].astype(np.int32)\n",
    "                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:\n",
    "                    df[col] = df[col].astype(np.int64)\n",
    "            else:\n",
    "                if c_min > np.finfo(np.float16).min and c_max < np.finfo(np.float16).max:\n",
    "                    df[col] = df[col].astype(np.float16)\n",
    "                elif c_min > np.finfo(np.float32).min and c_max < np.finfo(np.float32).max:\n",
    "                    df[col] = df[col].astype(np.float32)\n",
    "                else:\n",
    "                    df[col] = df[col].astype(np.float64)\n",
    "                    \n",
    "    end_mem = df.memory_usage().sum() / 1024**2\n",
    "    print('Memory usage after optimization is: {:.2f} MB'.format(end_mem))\n",
    "    print('Decreased by {:.1f}%'.format(100 * (start_mem - end_mem) / start_mem))\n",
    "    return df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据进行内存压缩"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Memory usage after optimization is: 1.74 MB\n",
      "Decreased by 70.8%\n",
      "Memory usage after optimization is: 3.49 MB\n",
      "Decreased by 41.7%\n",
      "Memory usage after optimization is: 3.24 MB\n",
      "Decreased by 66.7%\n",
      "Memory usage after optimization is: 32.43 MB\n",
      "Decreased by 69.6%\n"
     ]
    }
   ],
   "source": [
    "num_rows = None\n",
    "num_rows = 200 * 10000 # 1000条测试代码使用\n",
    "# num_rows = 1000\n",
    "\n",
    "train_file = './data_format1/train_format1.csv'\n",
    "test_file = './data_format1/test_format1.csv'\n",
    "\n",
    "user_info_file = './data_format1/user_info_format1.csv'\n",
    "user_log_file = './data_format1/user_log_format1.csv'\n",
    "\n",
    "train_data = reduce_mem_usage(read_csv(train_file, num_rows))\n",
    "test_data = reduce_mem_usage(read_csv(test_file, num_rows))\n",
    "\n",
    "user_info = reduce_mem_usage(read_csv(user_info_file, num_rows))\n",
    "user_log = reduce_mem_usage(read_csv(user_log_file, num_rows))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 260864 entries, 0 to 260863\n",
      "Data columns (total 3 columns):\n",
      " #   Column       Non-Null Count   Dtype\n",
      "---  ------       --------------   -----\n",
      " 0   user_id      260864 non-null  int32\n",
      " 1   merchant_id  260864 non-null  int16\n",
      " 2   label        260864 non-null  int8 \n",
      "dtypes: int16(1), int32(1), int8(1)\n",
      "memory usage: 1.7 MB\n"
     ]
    }
   ],
   "source": [
    "train_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 261477 entries, 0 to 261476\n",
      "Data columns (total 3 columns):\n",
      " #   Column       Non-Null Count   Dtype  \n",
      "---  ------       --------------   -----  \n",
      " 0   user_id      261477 non-null  int32  \n",
      " 1   merchant_id  261477 non-null  int16  \n",
      " 2   prob         0 non-null       float64\n",
      "dtypes: float64(1), int16(1), int32(1)\n",
      "memory usage: 3.5 MB\n"
     ]
    }
   ],
   "source": [
    "test_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 424170 entries, 0 to 424169\n",
      "Data columns (total 3 columns):\n",
      " #   Column     Non-Null Count   Dtype  \n",
      "---  ------     --------------   -----  \n",
      " 0   user_id    424170 non-null  int32  \n",
      " 1   age_range  421953 non-null  float16\n",
      " 2   gender     417734 non-null  float16\n",
      "dtypes: float16(2), int32(1)\n",
      "memory usage: 3.2 MB\n"
     ]
    }
   ],
   "source": [
    "user_info.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 2000000 entries, 0 to 1999999\n",
      "Data columns (total 7 columns):\n",
      " #   Column       Dtype  \n",
      "---  ------       -----  \n",
      " 0   user_id      int32  \n",
      " 1   item_id      int32  \n",
      " 2   cat_id       int16  \n",
      " 3   seller_id    int16  \n",
      " 4   brand_id     float16\n",
      " 5   time_stamp   int16  \n",
      " 6   action_type  int8   \n",
      "dtypes: float16(1), int16(3), int32(2), int8(1)\n",
      "memory usage: 32.4 MB\n"
     ]
    }
   ],
   "source": [
    "user_log.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据处理\n",
    "\n",
    "### 合并用户信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 161,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "del test_data['prob']\n",
    "all_data = train_data.append(test_data)\n",
    "all_data = all_data.merge(user_info,on=['user_id'],how='left')\n",
    "del train_data, test_data, user_info\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>merchant_id</th>\n",
       "      <th>label</th>\n",
       "      <th>age_range</th>\n",
       "      <th>gender</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>34176</td>\n",
       "      <td>3906</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>34176</td>\n",
       "      <td>121</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>34176</td>\n",
       "      <td>4356</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>34176</td>\n",
       "      <td>2217</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>230784</td>\n",
       "      <td>4818</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   user_id  merchant_id  label  age_range  gender\n",
       "0    34176         3906    0.0        6.0     0.0\n",
       "1    34176          121    0.0        6.0     0.0\n",
       "2    34176         4356    1.0        6.0     0.0\n",
       "3    34176         2217    0.0        6.0     0.0\n",
       "4   230784         4818    0.0        0.0     0.0"
      ]
     },
     "execution_count": 162,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 用户行为日志信息按时间进行排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "按时间排序\n",
    "\"\"\"\n",
    "user_log = user_log.sort_values(['user_id','time_stamp'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>item_id</th>\n",
       "      <th>cat_id</th>\n",
       "      <th>seller_id</th>\n",
       "      <th>brand_id</th>\n",
       "      <th>time_stamp</th>\n",
       "      <th>action_type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>61975</th>\n",
       "      <td>16</td>\n",
       "      <td>980982</td>\n",
       "      <td>437</td>\n",
       "      <td>650</td>\n",
       "      <td>4276.0</td>\n",
       "      <td>914</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61976</th>\n",
       "      <td>16</td>\n",
       "      <td>980982</td>\n",
       "      <td>437</td>\n",
       "      <td>650</td>\n",
       "      <td>4276.0</td>\n",
       "      <td>914</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61977</th>\n",
       "      <td>16</td>\n",
       "      <td>980982</td>\n",
       "      <td>437</td>\n",
       "      <td>650</td>\n",
       "      <td>4276.0</td>\n",
       "      <td>914</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61978</th>\n",
       "      <td>16</td>\n",
       "      <td>962763</td>\n",
       "      <td>19</td>\n",
       "      <td>650</td>\n",
       "      <td>4276.0</td>\n",
       "      <td>914</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61979</th>\n",
       "      <td>16</td>\n",
       "      <td>391126</td>\n",
       "      <td>437</td>\n",
       "      <td>650</td>\n",
       "      <td>4276.0</td>\n",
       "      <td>914</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       user_id  item_id  cat_id  seller_id  brand_id  time_stamp  action_type\n",
       "61975       16   980982     437        650    4276.0         914            0\n",
       "61976       16   980982     437        650    4276.0         914            0\n",
       "61977       16   980982     437        650    4276.0         914            0\n",
       "61978       16   962763      19        650    4276.0         914            0\n",
       "61979       16   391126     437        650    4276.0         914            0"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_log.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [],
   "source": [
    "# a = user_log.groupby('user_id').agg(agg_dict).reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {},
   "outputs": [],
   "source": [
    "# a.rename(columns=rename_dict)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 对每个用户的逐个合并所有的item_id, cat_id,seller_id,brand_id,time_stamp, action_type字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "合并数据\n",
    "\"\"\"\n",
    "list_join_func = lambda x: \" \".join([str(i) for i in x])\n",
    "\n",
    "\n",
    "agg_dict = {\n",
    "            'item_id' : list_join_func,\t\n",
    "            'cat_id' : list_join_func,\n",
    "            'seller_id' : list_join_func,\n",
    "            'brand_id' : list_join_func,\n",
    "            'time_stamp' : list_join_func,\n",
    "            'action_type' : list_join_func\n",
    "        }\n",
    "\n",
    "rename_dict = {\n",
    "            'item_id' : 'item_path',\n",
    "            'cat_id' : 'cat_path',\n",
    "            'seller_id' : 'seller_path',\n",
    "            'brand_id' : 'brand_path',\n",
    "            'time_stamp' : 'time_stamp_path',\n",
    "            'action_type' : 'action_type_path'\n",
    "        }\n",
    "\n",
    "# def merge_list(df_ID, join_columns, df_data, agg_dict, rename_dict):\n",
    "#     df_data = df_data.\\\n",
    "#                 groupby(join_columns).\\\n",
    "#                 agg(agg_dict).\\\n",
    "#                 reset_index().\\\n",
    "#                 rename(columns=rename_dict)\n",
    "    \n",
    "#     df_ID = df_ID.merge(df_data, on=join_columns, how=\"left\") \n",
    "#     return df_data,df_ID\n",
    "# all_data = merge_list(all_data, 'user_id', user_log, agg_dict, rename_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [],
   "source": [
    "user_log_path = user_log.groupby('user_id').agg(agg_dict).reset_index().rename(columns=rename_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>item_path</th>\n",
       "      <th>cat_path</th>\n",
       "      <th>seller_path</th>\n",
       "      <th>brand_path</th>\n",
       "      <th>time_stamp_path</th>\n",
       "      <th>action_type_path</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16</td>\n",
       "      <td>980982 980982 980982 962763 391126 827174 6731...</td>\n",
       "      <td>437 437 437 19 437 437 437 437 895 19 437 437 ...</td>\n",
       "      <td>650 650 650 650 650 650 650 650 3948 650 650 6...</td>\n",
       "      <td>4276.0 4276.0 4276.0 4276.0 4276.0 4276.0 4276...</td>\n",
       "      <td>914 914 914 914 914 914 914 914 914 914 914 91...</td>\n",
       "      <td>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 2 0 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19</td>\n",
       "      <td>388018 388018 88673 88673 88673 88673 846066 5...</td>\n",
       "      <td>949 949 614 614 614 614 420 1401 948 948 513 1...</td>\n",
       "      <td>2772 2772 4066 4066 4066 4066 4951 4951 2872 2...</td>\n",
       "      <td>2112.0 2112.0 1552.0 1552.0 1552.0 1552.0 5200...</td>\n",
       "      <td>710 710 711 711 711 711 908 908 1105 1105 1105...</td>\n",
       "      <td>0 2 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>41</td>\n",
       "      <td>60215 1004605 60215 60215 60215 60215 628525 5...</td>\n",
       "      <td>1308 1308 1308 1308 1308 1308 1271 656 656 656...</td>\n",
       "      <td>2128 3207 2128 2128 2128 2128 3142 4618 4618 4...</td>\n",
       "      <td>3848.0 3848.0 3848.0 3848.0 3848.0 3848.0 1014...</td>\n",
       "      <td>521 521 521 521 521 522 529 828 828 828 828 82...</td>\n",
       "      <td>0 0 0 2 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>56</td>\n",
       "      <td>889499 528459 765746 553259 889499 22435 40047...</td>\n",
       "      <td>662 1075 662 1577 662 11 184 1604 11 11 177 11...</td>\n",
       "      <td>4048 601 3104 3828 4048 4766 2419 2768 2565 26...</td>\n",
       "      <td>5360.0 1040.0 8240.0 1446.0 5360.0 4360.0 3428...</td>\n",
       "      <td>517 520 525 528 602 602 610 610 610 610 610 61...</td>\n",
       "      <td>3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>155</td>\n",
       "      <td>979639 890128 981780 211366 211366 797946 4567...</td>\n",
       "      <td>267 1271 1505 267 267 1075 1075 407 407 1075 4...</td>\n",
       "      <td>2429 4785 3784 800 800 1595 1418 2662 2662 315...</td>\n",
       "      <td>2276.0 1422.0 5692.0 6328.0 6328.0 5800.0 7140...</td>\n",
       "      <td>529 529 602 604 604 607 607 607 607 607 607 60...</td>\n",
       "      <td>0 0 0 2 2 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 2 ...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   user_id                                          item_path  \\\n",
       "0       16  980982 980982 980982 962763 391126 827174 6731...   \n",
       "1       19  388018 388018 88673 88673 88673 88673 846066 5...   \n",
       "2       41  60215 1004605 60215 60215 60215 60215 628525 5...   \n",
       "3       56  889499 528459 765746 553259 889499 22435 40047...   \n",
       "4      155  979639 890128 981780 211366 211366 797946 4567...   \n",
       "\n",
       "                                            cat_path  \\\n",
       "0  437 437 437 19 437 437 437 437 895 19 437 437 ...   \n",
       "1  949 949 614 614 614 614 420 1401 948 948 513 1...   \n",
       "2  1308 1308 1308 1308 1308 1308 1271 656 656 656...   \n",
       "3  662 1075 662 1577 662 11 184 1604 11 11 177 11...   \n",
       "4  267 1271 1505 267 267 1075 1075 407 407 1075 4...   \n",
       "\n",
       "                                         seller_path  \\\n",
       "0  650 650 650 650 650 650 650 650 3948 650 650 6...   \n",
       "1  2772 2772 4066 4066 4066 4066 4951 4951 2872 2...   \n",
       "2  2128 3207 2128 2128 2128 2128 3142 4618 4618 4...   \n",
       "3  4048 601 3104 3828 4048 4766 2419 2768 2565 26...   \n",
       "4  2429 4785 3784 800 800 1595 1418 2662 2662 315...   \n",
       "\n",
       "                                          brand_path  \\\n",
       "0  4276.0 4276.0 4276.0 4276.0 4276.0 4276.0 4276...   \n",
       "1  2112.0 2112.0 1552.0 1552.0 1552.0 1552.0 5200...   \n",
       "2  3848.0 3848.0 3848.0 3848.0 3848.0 3848.0 1014...   \n",
       "3  5360.0 1040.0 8240.0 1446.0 5360.0 4360.0 3428...   \n",
       "4  2276.0 1422.0 5692.0 6328.0 6328.0 5800.0 7140...   \n",
       "\n",
       "                                     time_stamp_path  \\\n",
       "0  914 914 914 914 914 914 914 914 914 914 914 91...   \n",
       "1  710 710 711 711 711 711 908 908 1105 1105 1105...   \n",
       "2  521 521 521 521 521 522 529 828 828 828 828 82...   \n",
       "3  517 520 525 528 602 602 610 610 610 610 610 61...   \n",
       "4  529 529 602 604 604 607 607 607 607 607 607 60...   \n",
       "\n",
       "                                    action_type_path  \n",
       "0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 2 0 ...  \n",
       "1  0 2 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...  \n",
       "2  0 0 0 2 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 ...  \n",
       "3  3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 ...  \n",
       "4  0 0 0 2 2 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 2 ...  "
      ]
     },
     "execution_count": 169,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_log_path.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_data_path = all_data.merge(user_log_path,on='user_id')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>merchant_id</th>\n",
       "      <th>label</th>\n",
       "      <th>age_range</th>\n",
       "      <th>gender</th>\n",
       "      <th>item_path</th>\n",
       "      <th>cat_path</th>\n",
       "      <th>seller_path</th>\n",
       "      <th>brand_path</th>\n",
       "      <th>time_stamp_path</th>\n",
       "      <th>action_type_path</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>105600</td>\n",
       "      <td>1487</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>986160 681407 681407 910680 681407 592698 3693...</td>\n",
       "      <td>35 1554 1554 119 1554 662 1095 662 35 833 833 ...</td>\n",
       "      <td>4811 4811 4811 1897 4811 3315 2925 1340 1875 4...</td>\n",
       "      <td>127.0 127.0 127.0 4704.0 127.0 1605.0 6000.0 1...</td>\n",
       "      <td>518 518 518 520 520 524 524 524 525 525 525 52...</td>\n",
       "      <td>2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>110976</td>\n",
       "      <td>159</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>396970 961553 627712 926681 1012423 825576 149...</td>\n",
       "      <td>1023 420 407 1505 962 602 184 1606 351 1505 11...</td>\n",
       "      <td>1435 1648 223 3178 2418 1614 3004 2511 2285 78...</td>\n",
       "      <td>5504.0 7780.0 1751.0 7540.0 6652.0 8116.0 5328...</td>\n",
       "      <td>517 520 522 522 527 530 530 530 601 601 602 60...</td>\n",
       "      <td>2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 0 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>374400</td>\n",
       "      <td>302</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>256546 202393 927572 2587 10956 549283 270303 ...</td>\n",
       "      <td>1188 646 1175 1188 1414 681 1175 681 681 115 1...</td>\n",
       "      <td>805 390 4252 3979 1228 2029 2029 2029 4252 923...</td>\n",
       "      <td>1842.0 5920.0 133.0 6304.0 7584.0 133.0 133.0 ...</td>\n",
       "      <td>517 604 604 604 607 609 609 609 609 615 621 62...</td>\n",
       "      <td>2 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>189312</td>\n",
       "      <td>1760</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>290583 166235 556025 217894 166235 556025 5589...</td>\n",
       "      <td>601 601 601 601 601 601 601 601 601 601 601 60...</td>\n",
       "      <td>3139 3139 3524 3139 3139 3524 3139 3139 3139 3...</td>\n",
       "      <td>549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....</td>\n",
       "      <td>924 924 924 924 924 924 924 924 924 924 924 92...</td>\n",
       "      <td>0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>189312</td>\n",
       "      <td>2511</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>290583 166235 556025 217894 166235 556025 5589...</td>\n",
       "      <td>601 601 601 601 601 601 601 601 601 601 601 60...</td>\n",
       "      <td>3139 3139 3524 3139 3139 3524 3139 3139 3139 3...</td>\n",
       "      <td>549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....</td>\n",
       "      <td>924 924 924 924 924 924 924 924 924 924 924 92...</td>\n",
       "      <td>0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   user_id  merchant_id  label  age_range  gender  \\\n",
       "0   105600         1487    0.0        6.0     1.0   \n",
       "1   110976          159    0.0        5.0     0.0   \n",
       "2   374400          302    0.0        5.0     1.0   \n",
       "3   189312         1760    0.0        4.0     0.0   \n",
       "4   189312         2511    0.0        4.0     0.0   \n",
       "\n",
       "                                           item_path  \\\n",
       "0  986160 681407 681407 910680 681407 592698 3693...   \n",
       "1  396970 961553 627712 926681 1012423 825576 149...   \n",
       "2  256546 202393 927572 2587 10956 549283 270303 ...   \n",
       "3  290583 166235 556025 217894 166235 556025 5589...   \n",
       "4  290583 166235 556025 217894 166235 556025 5589...   \n",
       "\n",
       "                                            cat_path  \\\n",
       "0  35 1554 1554 119 1554 662 1095 662 35 833 833 ...   \n",
       "1  1023 420 407 1505 962 602 184 1606 351 1505 11...   \n",
       "2  1188 646 1175 1188 1414 681 1175 681 681 115 1...   \n",
       "3  601 601 601 601 601 601 601 601 601 601 601 60...   \n",
       "4  601 601 601 601 601 601 601 601 601 601 601 60...   \n",
       "\n",
       "                                         seller_path  \\\n",
       "0  4811 4811 4811 1897 4811 3315 2925 1340 1875 4...   \n",
       "1  1435 1648 223 3178 2418 1614 3004 2511 2285 78...   \n",
       "2  805 390 4252 3979 1228 2029 2029 2029 4252 923...   \n",
       "3  3139 3139 3524 3139 3139 3524 3139 3139 3139 3...   \n",
       "4  3139 3139 3524 3139 3139 3524 3139 3139 3139 3...   \n",
       "\n",
       "                                          brand_path  \\\n",
       "0  127.0 127.0 127.0 4704.0 127.0 1605.0 6000.0 1...   \n",
       "1  5504.0 7780.0 1751.0 7540.0 6652.0 8116.0 5328...   \n",
       "2  1842.0 5920.0 133.0 6304.0 7584.0 133.0 133.0 ...   \n",
       "3  549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....   \n",
       "4  549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....   \n",
       "\n",
       "                                     time_stamp_path  \\\n",
       "0  518 518 518 520 520 524 524 524 525 525 525 52...   \n",
       "1  517 520 522 522 527 530 530 530 601 601 602 60...   \n",
       "2  517 604 604 604 607 609 609 609 609 615 621 62...   \n",
       "3  924 924 924 924 924 924 924 924 924 924 924 92...   \n",
       "4  924 924 924 924 924 924 924 924 924 924 924 92...   \n",
       "\n",
       "                                    action_type_path  \n",
       "0  2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...  \n",
       "1  2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 0 ...  \n",
       "2  2 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...  \n",
       "3  0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...  \n",
       "4  0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...  "
      ]
     },
     "execution_count": 171,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_data_path.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 删除数据并回收内存"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"\n",
    "删除不需要的数据\n",
    "\"\"\"\n",
    "del user_log\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 定义数据统计函数\n",
    "\n",
    "### 统计数据的总数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cnt_(x):\n",
    "    try:\n",
    "        return len(x.split(' '))\n",
    "    except:\n",
    "        return -1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计唯一数据总数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {},
   "outputs": [],
   "source": [
    "def nunique_(x):\n",
    "    try:\n",
    "        return len(set(x.split(' ')))\n",
    "    except:\n",
    "        return -1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计数据最大值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {},
   "outputs": [],
   "source": [
    "def max_(x):\n",
    "    try:\n",
    "        return np.max([int(i) for i in x.split(' ')])\n",
    "    except:\n",
    "        return -1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计数据最小值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "metadata": {},
   "outputs": [],
   "source": [
    "def min_(x):\n",
    "    try:\n",
    "        return np.min([int(i) for i in x.split(' ')])\n",
    "    except:\n",
    "        return -1  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计数据的标准差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [],
   "source": [
    "def std_(x):\n",
    "    try:\n",
    "        return np.std([float(i) for i in x.split(' ')])\n",
    "    except:\n",
    "        return -1 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计数据中top N的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "metadata": {},
   "outputs": [],
   "source": [
    "def most_n(x, n):\n",
    "    try:\n",
    "        return Counter(x.split(' ')).most_common(n)[n-1][0]\n",
    "    except:\n",
    "        return -1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计数据中top N数据的总数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "metadata": {},
   "outputs": [],
   "source": [
    "def most_n_cnt(x, n):\n",
    "    try:\n",
    "        return Counter(x.split(' ')).most_common(n)[n-1][1]\n",
    "    except:\n",
    "        return -1   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "metadata": {},
   "outputs": [],
   "source": [
    "def user_cnt(df_data, single_col, name):\n",
    "    df_data[name] = df_data[single_col].apply(cnt_)\n",
    "    return df_data\n",
    "\n",
    "def user_nunique(df_data, single_col, name):\n",
    "    df_data[name] = df_data[single_col].apply(nunique_)\n",
    "    return df_data\n",
    "    \n",
    "def user_max(df_data, single_col, name):\n",
    "    df_data[name] = df_data[single_col].apply(max_)\n",
    "    return df_data\n",
    "\n",
    "def user_min(df_data, single_col, name):\n",
    "    df_data[name] = df_data[single_col].apply(min_)\n",
    "    return df_data\n",
    "    \n",
    "def user_std(df_data, single_col, name):\n",
    "    df_data[name] = df_data[single_col].apply(std_)\n",
    "    return df_data\n",
    "\n",
    "def user_most_n(df_data, single_col, name, n=1):\n",
    "    func = lambda x: most_n(x, n)\n",
    "    df_data[name] = df_data[single_col].apply(func)\n",
    "    return df_data\n",
    "\n",
    "def user_most_n_cnt(df_data, single_col, name, n=1):\n",
    "    func = lambda x: most_n_cnt(x, n)\n",
    "    df_data[name] = df_data[single_col].apply(func)\n",
    "    return df_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 提取商铺的基本统计特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 181,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_data_test = all_data_path.head(2000)\n",
    "#all_data_test = all_data_path\n",
    "# 统计用户 点击、浏览、加购、购买行为\n",
    "# 总次数\n",
    "all_data_test = user_cnt(all_data_test,  'seller_path', 'user_cnt')\n",
    "# 不同店铺个数\n",
    "all_data_test = user_nunique(all_data_test,  'seller_path', 'seller_nunique')\n",
    "# 不同品类个数\n",
    "all_data_test = user_nunique(all_data_test,  'cat_path', 'cat_nunique')\n",
    "# 不同品牌个数\n",
    "all_data_test = user_nunique(all_data_test,  'brand_path', 'brand_nunique')\n",
    "# 不同商品个数\n",
    "all_data_test = user_nunique(all_data_test,  'item_path', 'item_nunique')\n",
    "# 活跃天数\n",
    "all_data_test = user_nunique(all_data_test,  'time_stamp_path', 'time_stamp_nunique')\n",
    "# 不用行为种数\n",
    "all_data_test = user_nunique(all_data_test,  'action_type_path', 'action_type_nunique')\n",
    "# ...."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 182,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>merchant_id</th>\n",
       "      <th>label</th>\n",
       "      <th>age_range</th>\n",
       "      <th>gender</th>\n",
       "      <th>item_path</th>\n",
       "      <th>cat_path</th>\n",
       "      <th>seller_path</th>\n",
       "      <th>brand_path</th>\n",
       "      <th>time_stamp_path</th>\n",
       "      <th>action_type_path</th>\n",
       "      <th>user_cnt</th>\n",
       "      <th>seller_nunique</th>\n",
       "      <th>cat_nunique</th>\n",
       "      <th>brand_nunique</th>\n",
       "      <th>item_nunique</th>\n",
       "      <th>time_stamp_nunique</th>\n",
       "      <th>action_type_nunique</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>105600</td>\n",
       "      <td>1487</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>986160 681407 681407 910680 681407 592698 3693...</td>\n",
       "      <td>35 1554 1554 119 1554 662 1095 662 35 833 833 ...</td>\n",
       "      <td>4811 4811 4811 1897 4811 3315 2925 1340 1875 4...</td>\n",
       "      <td>127.0 127.0 127.0 4704.0 127.0 1605.0 6000.0 1...</td>\n",
       "      <td>518 518 518 520 520 524 524 524 525 525 525 52...</td>\n",
       "      <td>2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "      <td>310</td>\n",
       "      <td>96</td>\n",
       "      <td>37</td>\n",
       "      <td>88</td>\n",
       "      <td>217</td>\n",
       "      <td>29</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>110976</td>\n",
       "      <td>159</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>396970 961553 627712 926681 1012423 825576 149...</td>\n",
       "      <td>1023 420 407 1505 962 602 184 1606 351 1505 11...</td>\n",
       "      <td>1435 1648 223 3178 2418 1614 3004 2511 2285 78...</td>\n",
       "      <td>5504.0 7780.0 1751.0 7540.0 6652.0 8116.0 5328...</td>\n",
       "      <td>517 520 522 522 527 530 530 530 601 601 602 60...</td>\n",
       "      <td>2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 0 ...</td>\n",
       "      <td>274</td>\n",
       "      <td>181</td>\n",
       "      <td>70</td>\n",
       "      <td>159</td>\n",
       "      <td>233</td>\n",
       "      <td>52</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>374400</td>\n",
       "      <td>302</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>256546 202393 927572 2587 10956 549283 270303 ...</td>\n",
       "      <td>1188 646 1175 1188 1414 681 1175 681 681 115 1...</td>\n",
       "      <td>805 390 4252 3979 1228 2029 2029 2029 4252 923...</td>\n",
       "      <td>1842.0 5920.0 133.0 6304.0 7584.0 133.0 133.0 ...</td>\n",
       "      <td>517 604 604 604 607 609 609 609 609 615 621 62...</td>\n",
       "      <td>2 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "      <td>278</td>\n",
       "      <td>57</td>\n",
       "      <td>59</td>\n",
       "      <td>62</td>\n",
       "      <td>148</td>\n",
       "      <td>35</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>189312</td>\n",
       "      <td>1760</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>290583 166235 556025 217894 166235 556025 5589...</td>\n",
       "      <td>601 601 601 601 601 601 601 601 601 601 601 60...</td>\n",
       "      <td>3139 3139 3524 3139 3139 3524 3139 3139 3139 3...</td>\n",
       "      <td>549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....</td>\n",
       "      <td>924 924 924 924 924 924 924 924 924 924 924 92...</td>\n",
       "      <td>0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "      <td>237</td>\n",
       "      <td>49</td>\n",
       "      <td>35</td>\n",
       "      <td>45</td>\n",
       "      <td>170</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>189312</td>\n",
       "      <td>2511</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>290583 166235 556025 217894 166235 556025 5589...</td>\n",
       "      <td>601 601 601 601 601 601 601 601 601 601 601 60...</td>\n",
       "      <td>3139 3139 3524 3139 3139 3524 3139 3139 3139 3...</td>\n",
       "      <td>549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....</td>\n",
       "      <td>924 924 924 924 924 924 924 924 924 924 924 92...</td>\n",
       "      <td>0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...</td>\n",
       "      <td>237</td>\n",
       "      <td>49</td>\n",
       "      <td>35</td>\n",
       "      <td>45</td>\n",
       "      <td>170</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   user_id  merchant_id  label  age_range  gender  \\\n",
       "0   105600         1487    0.0        6.0     1.0   \n",
       "1   110976          159    0.0        5.0     0.0   \n",
       "2   374400          302    0.0        5.0     1.0   \n",
       "3   189312         1760    0.0        4.0     0.0   \n",
       "4   189312         2511    0.0        4.0     0.0   \n",
       "\n",
       "                                           item_path  \\\n",
       "0  986160 681407 681407 910680 681407 592698 3693...   \n",
       "1  396970 961553 627712 926681 1012423 825576 149...   \n",
       "2  256546 202393 927572 2587 10956 549283 270303 ...   \n",
       "3  290583 166235 556025 217894 166235 556025 5589...   \n",
       "4  290583 166235 556025 217894 166235 556025 5589...   \n",
       "\n",
       "                                            cat_path  \\\n",
       "0  35 1554 1554 119 1554 662 1095 662 35 833 833 ...   \n",
       "1  1023 420 407 1505 962 602 184 1606 351 1505 11...   \n",
       "2  1188 646 1175 1188 1414 681 1175 681 681 115 1...   \n",
       "3  601 601 601 601 601 601 601 601 601 601 601 60...   \n",
       "4  601 601 601 601 601 601 601 601 601 601 601 60...   \n",
       "\n",
       "                                         seller_path  \\\n",
       "0  4811 4811 4811 1897 4811 3315 2925 1340 1875 4...   \n",
       "1  1435 1648 223 3178 2418 1614 3004 2511 2285 78...   \n",
       "2  805 390 4252 3979 1228 2029 2029 2029 4252 923...   \n",
       "3  3139 3139 3524 3139 3139 3524 3139 3139 3139 3...   \n",
       "4  3139 3139 3524 3139 3139 3524 3139 3139 3139 3...   \n",
       "\n",
       "                                          brand_path  \\\n",
       "0  127.0 127.0 127.0 4704.0 127.0 1605.0 6000.0 1...   \n",
       "1  5504.0 7780.0 1751.0 7540.0 6652.0 8116.0 5328...   \n",
       "2  1842.0 5920.0 133.0 6304.0 7584.0 133.0 133.0 ...   \n",
       "3  549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....   \n",
       "4  549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....   \n",
       "\n",
       "                                     time_stamp_path  \\\n",
       "0  518 518 518 520 520 524 524 524 525 525 525 52...   \n",
       "1  517 520 522 522 527 530 530 530 601 601 602 60...   \n",
       "2  517 604 604 604 607 609 609 609 609 615 621 62...   \n",
       "3  924 924 924 924 924 924 924 924 924 924 924 92...   \n",
       "4  924 924 924 924 924 924 924 924 924 924 924 92...   \n",
       "\n",
       "                                    action_type_path  user_cnt  \\\n",
       "0  2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...       310   \n",
       "1  2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 0 ...       274   \n",
       "2  2 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...       278   \n",
       "3  0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...       237   \n",
       "4  0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...       237   \n",
       "\n",
       "   seller_nunique  cat_nunique  brand_nunique  item_nunique  \\\n",
       "0              96           37             88           217   \n",
       "1             181           70            159           233   \n",
       "2              57           59             62           148   \n",
       "3              49           35             45           170   \n",
       "4              49           35             45           170   \n",
       "\n",
       "   time_stamp_nunique  action_type_nunique  \n",
       "0                  29                    2  \n",
       "1                  52                    3  \n",
       "2                  35                    3  \n",
       "3                   9                    2  \n",
       "4                   9                    2  "
      ]
     },
     "execution_count": 182,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_data_test.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 最晚时间\n",
    "all_data_test = user_max(all_data_test,  'action_type_path', 'time_stamp_max')\n",
    "# 最早时间\n",
    "all_data_test = user_min(all_data_test,  'action_type_path', 'time_stamp_min')\n",
    "# 活跃天数方差\n",
    "all_data_test = user_std(all_data_test,  'action_type_path', 'time_stamp_std')\n",
    "# 最早和最晚相差天数\n",
    "all_data_test['time_stamp_range'] = all_data_test['time_stamp_max'] - all_data_test['time_stamp_min']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 用户最喜欢的店铺\n",
    "all_data_test = user_most_n(all_data_test, 'seller_path', 'seller_most_1', n=1)\n",
    "# 最喜欢的类目\n",
    "all_data_test = user_most_n(all_data_test, 'cat_path', 'cat_most_1', n=1)\n",
    "# 最喜欢的品牌\n",
    "all_data_test = user_most_n(all_data_test, 'brand_path', 'brand_most_1', n=1)\n",
    "# 最常见的行为动作\n",
    "all_data_test = user_most_n(all_data_test, 'action_type_path', 'action_type_1', n=1)\n",
    "# ....."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 用户最喜欢的店铺 行为次数\n",
    "all_data_test = user_most_n_cnt(all_data_test, 'seller_path', 'seller_most_1_cnt', n=1)\n",
    "# 最喜欢的类目 行为次数\n",
    "all_data_test = user_most_n_cnt(all_data_test, 'cat_path', 'cat_most_1_cnt', n=1)\n",
    "# 最喜欢的品牌 行为次数\n",
    "all_data_test = user_most_n_cnt(all_data_test, 'brand_path', 'brand_most_1_cnt', n=1)\n",
    "# 最常见的行为动作 行为次数\n",
    "all_data_test = user_most_n_cnt(all_data_test, 'action_type_path', 'action_type_1_cnt', n=1)\n",
    "# ....."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 分开统计用户的点击，加购，购买，收藏特征\n",
    "\n",
    "### 不同行为的业务函数定义"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 点击、加购、购买、收藏 分开统计\n",
    "\"\"\"\n",
    "统计基本特征函数  \n",
    "-- 知识点二\n",
    "-- 根据不同行为的业务函数\n",
    "-- 提取不同特征\n",
    "\"\"\"\n",
    "def col_cnt_(df_data, columns_list, action_type):\n",
    "    try:\n",
    "        data_dict = {}\n",
    "\n",
    "        col_list = copy.deepcopy(columns_list)\n",
    "        if action_type != None:\n",
    "            col_list += ['action_type_path']\n",
    "\n",
    "        for col in col_list:\n",
    "            data_dict[col] = df_data[col].split(' ')\n",
    "\n",
    "        path_len = len(data_dict[col])\n",
    "\n",
    "        data_out = []\n",
    "        for i_ in range(path_len):\n",
    "            data_txt = ''\n",
    "            for col_ in columns_list:\n",
    "                if data_dict['action_type_path'][i_] == action_type:\n",
    "                    data_txt += '_' + data_dict[col_][i_]\n",
    "            data_out.append(data_txt)\n",
    "\n",
    "        return len(data_out)  \n",
    "    except:\n",
    "        return -1\n",
    "\n",
    "def col_nuique_(df_data, columns_list, action_type):\n",
    "    try:\n",
    "        data_dict = {}\n",
    "\n",
    "        col_list = copy.deepcopy(columns_list)\n",
    "        if action_type != None:\n",
    "            col_list += ['action_type_path']\n",
    "\n",
    "        for col in col_list:\n",
    "            data_dict[col] = df_data[col].split(' ')\n",
    "\n",
    "        path_len = len(data_dict[col])\n",
    "\n",
    "        data_out = []\n",
    "        for i_ in range(path_len):\n",
    "            data_txt = ''\n",
    "            for col_ in columns_list:\n",
    "                if data_dict['action_type_path'][i_] == action_type:\n",
    "                    data_txt += '_' + data_dict[col_][i_]\n",
    "            data_out.append(data_txt)\n",
    "\n",
    "        return len(set(data_out))\n",
    "    except:\n",
    "        return -1\n",
    "    \n",
    "\n",
    "def user_col_cnt(df_data, columns_list, action_type, name):\n",
    "    df_data[name] = df_data.apply(lambda x: col_cnt_(x, columns_list, action_type), axis=1)\n",
    "    return df_data\n",
    "\n",
    "def user_col_nunique(df_data, columns_list, action_type, name):\n",
    "    df_data[name] = df_data.apply(lambda x: col_nuique_(x, columns_list, action_type), axis=1)\n",
    "    return df_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计店铺被用户点击次数，加购次数，购买次数，收藏次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 点击次数\n",
    "all_data_test = user_col_cnt(all_data_test,  ['seller_path'], '0', 'user_cnt_0')\n",
    "# 加购次数\n",
    "all_data_test = user_col_cnt(all_data_test,  ['seller_path'], '1', 'user_cnt_1')\n",
    "# 购买次数\n",
    "all_data_test = user_col_cnt(all_data_test,  ['seller_path'], '2', 'user_cnt_2')\n",
    "# 收藏次数\n",
    "all_data_test = user_col_cnt(all_data_test,  ['seller_path'], '3', 'user_cnt_3')\n",
    "\n",
    "\n",
    "# 不同店铺个数\n",
    "all_data_test = user_col_nunique(all_data_test,  ['seller_path'], '0', 'seller_nunique_0')\n",
    "# ...."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>merchant_id</th>\n",
       "      <th>label</th>\n",
       "      <th>age_range</th>\n",
       "      <th>gender</th>\n",
       "      <th>item_path</th>\n",
       "      <th>cat_path</th>\n",
       "      <th>seller_path</th>\n",
       "      <th>brand_path</th>\n",
       "      <th>time_stamp_path</th>\n",
       "      <th>...</th>\n",
       "      <th>action_type_1</th>\n",
       "      <th>seller_most_1_cnt</th>\n",
       "      <th>cat_most_1_cnt</th>\n",
       "      <th>brand_most_1_cnt</th>\n",
       "      <th>action_type_1_cnt</th>\n",
       "      <th>user_cnt_0</th>\n",
       "      <th>user_cnt_1</th>\n",
       "      <th>user_cnt_2</th>\n",
       "      <th>user_cnt_3</th>\n",
       "      <th>seller_nunique_0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>105600</td>\n",
       "      <td>1487</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>986160 681407 681407 910680 681407 592698 3693...</td>\n",
       "      <td>35 1554 1554 119 1554 662 1095 662 35 833 833 ...</td>\n",
       "      <td>4811 4811 4811 1897 4811 3315 2925 1340 1875 4...</td>\n",
       "      <td>127.0 127.0 127.0 4704.0 127.0 1605.0 6000.0 1...</td>\n",
       "      <td>518 518 518 520 520 524 524 524 525 525 525 52...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>35</td>\n",
       "      <td>43</td>\n",
       "      <td>35</td>\n",
       "      <td>299</td>\n",
       "      <td>310</td>\n",
       "      <td>310</td>\n",
       "      <td>310</td>\n",
       "      <td>310</td>\n",
       "      <td>97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>110976</td>\n",
       "      <td>159</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>396970 961553 627712 926681 1012423 825576 149...</td>\n",
       "      <td>1023 420 407 1505 962 602 184 1606 351 1505 11...</td>\n",
       "      <td>1435 1648 223 3178 2418 1614 3004 2511 2285 78...</td>\n",
       "      <td>5504.0 7780.0 1751.0 7540.0 6652.0 8116.0 5328...</td>\n",
       "      <td>517 520 522 522 527 530 530 530 601 601 602 60...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>56</td>\n",
       "      <td>11</td>\n",
       "      <td>259</td>\n",
       "      <td>274</td>\n",
       "      <td>274</td>\n",
       "      <td>274</td>\n",
       "      <td>274</td>\n",
       "      <td>181</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>374400</td>\n",
       "      <td>302</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>256546 202393 927572 2587 10956 549283 270303 ...</td>\n",
       "      <td>1188 646 1175 1188 1414 681 1175 681 681 115 1...</td>\n",
       "      <td>805 390 4252 3979 1228 2029 2029 2029 4252 923...</td>\n",
       "      <td>1842.0 5920.0 133.0 6304.0 7584.0 133.0 133.0 ...</td>\n",
       "      <td>517 604 604 604 607 609 609 609 609 615 621 62...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>93</td>\n",
       "      <td>29</td>\n",
       "      <td>48</td>\n",
       "      <td>241</td>\n",
       "      <td>278</td>\n",
       "      <td>278</td>\n",
       "      <td>278</td>\n",
       "      <td>278</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>189312</td>\n",
       "      <td>1760</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>290583 166235 556025 217894 166235 556025 5589...</td>\n",
       "      <td>601 601 601 601 601 601 601 601 601 601 601 60...</td>\n",
       "      <td>3139 3139 3524 3139 3139 3524 3139 3139 3139 3...</td>\n",
       "      <td>549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....</td>\n",
       "      <td>924 924 924 924 924 924 924 924 924 924 924 92...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>45</td>\n",
       "      <td>68</td>\n",
       "      <td>45</td>\n",
       "      <td>228</td>\n",
       "      <td>237</td>\n",
       "      <td>237</td>\n",
       "      <td>237</td>\n",
       "      <td>237</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>189312</td>\n",
       "      <td>2511</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>290583 166235 556025 217894 166235 556025 5589...</td>\n",
       "      <td>601 601 601 601 601 601 601 601 601 601 601 60...</td>\n",
       "      <td>3139 3139 3524 3139 3139 3524 3139 3139 3139 3...</td>\n",
       "      <td>549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....</td>\n",
       "      <td>924 924 924 924 924 924 924 924 924 924 924 92...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>45</td>\n",
       "      <td>68</td>\n",
       "      <td>45</td>\n",
       "      <td>228</td>\n",
       "      <td>237</td>\n",
       "      <td>237</td>\n",
       "      <td>237</td>\n",
       "      <td>237</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995</th>\n",
       "      <td>305721</td>\n",
       "      <td>3734</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>195526 195526 195526 195526 1002121 36379 8135...</td>\n",
       "      <td>384 384 384 384 1075 1075 1075 1349 1349 1349 ...</td>\n",
       "      <td>4696 4696 4696 4696 494 3863 4741 1251 2269 12...</td>\n",
       "      <td>6548.0 6548.0 6548.0 6548.0 7288.0 2960.0 7088...</td>\n",
       "      <td>610 610 610 630 707 707 707 1109 1109 1109 110...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>32</td>\n",
       "      <td>35</td>\n",
       "      <td>35</td>\n",
       "      <td>35</td>\n",
       "      <td>35</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1996</th>\n",
       "      <td>109881</td>\n",
       "      <td>2639</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>288225 812720 500918 500918 698153 507072 5009...</td>\n",
       "      <td>35 681 295 295 1518 1518 295 1468 1518 1468 81...</td>\n",
       "      <td>696 899 3398 3398 3398 3398 3398 3398 3398 339...</td>\n",
       "      <td>3600.0 6568.0 30.0 30.0 30.0 30.0 30.0 30.0 30...</td>\n",
       "      <td>524 528 530 530 530 530 530 530 530 530 705 70...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>67</td>\n",
       "      <td>32</td>\n",
       "      <td>66</td>\n",
       "      <td>264</td>\n",
       "      <td>284</td>\n",
       "      <td>284</td>\n",
       "      <td>284</td>\n",
       "      <td>284</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1997</th>\n",
       "      <td>185145</td>\n",
       "      <td>4950</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>952981 502801 917988 917988 143799 667127 4004...</td>\n",
       "      <td>898 795 354 354 833 1150 843 898 898 898 898 8...</td>\n",
       "      <td>3319 390 1338 1338 3149 3319 1338 3319 3319 33...</td>\n",
       "      <td>5508.0 6876.0 4740.0 4740.0 5388.0 1283.0 4740...</td>\n",
       "      <td>515 516 517 517 604 606 606 619 619 619 619 61...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>15</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>74</td>\n",
       "      <td>84</td>\n",
       "      <td>84</td>\n",
       "      <td>84</td>\n",
       "      <td>84</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1998</th>\n",
       "      <td>131385</td>\n",
       "      <td>1582</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>771829 332521 332521 60522 60522 672487 711909...</td>\n",
       "      <td>1213 1075 1075 1213 1213 1656 1075 1213 1213 1...</td>\n",
       "      <td>2588 3168 3168 2160 2160 2439 3168 2160 2588 4...</td>\n",
       "      <td>2760.0 4504.0 4504.0 1195.0 1195.0 1307.0 4504...</td>\n",
       "      <td>531 531 531 531 531 531 531 531 531 531 531 53...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>21</td>\n",
       "      <td>17</td>\n",
       "      <td>84</td>\n",
       "      <td>92</td>\n",
       "      <td>92</td>\n",
       "      <td>92</td>\n",
       "      <td>92</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999</th>\n",
       "      <td>7737</td>\n",
       "      <td>2066</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>305283 990086 985582 741215 741215 741215 6061...</td>\n",
       "      <td>1271 1271 812 464 464 464 1577 464 464 464 464...</td>\n",
       "      <td>1500 540 1849 176 176 176 3028 176 176 176 176...</td>\n",
       "      <td>7284.0 5384.0 5576.0 6664.0 6664.0 6664.0 4608...</td>\n",
       "      <td>511 511 514 520 520 520 520 520 520 520 520 52...</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>55</td>\n",
       "      <td>22</td>\n",
       "      <td>28</td>\n",
       "      <td>189</td>\n",
       "      <td>210</td>\n",
       "      <td>210</td>\n",
       "      <td>210</td>\n",
       "      <td>210</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2000 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      user_id  merchant_id  label  age_range  gender  \\\n",
       "0      105600         1487    0.0        6.0     1.0   \n",
       "1      110976          159    0.0        5.0     0.0   \n",
       "2      374400          302    0.0        5.0     1.0   \n",
       "3      189312         1760    0.0        4.0     0.0   \n",
       "4      189312         2511    0.0        4.0     0.0   \n",
       "...       ...          ...    ...        ...     ...   \n",
       "1995   305721         3734    0.0        3.0     1.0   \n",
       "1996   109881         2639    0.0        4.0     0.0   \n",
       "1997   185145         4950    0.0        4.0     1.0   \n",
       "1998   131385         1582    0.0        3.0     1.0   \n",
       "1999     7737         2066    0.0        4.0     0.0   \n",
       "\n",
       "                                              item_path  \\\n",
       "0     986160 681407 681407 910680 681407 592698 3693...   \n",
       "1     396970 961553 627712 926681 1012423 825576 149...   \n",
       "2     256546 202393 927572 2587 10956 549283 270303 ...   \n",
       "3     290583 166235 556025 217894 166235 556025 5589...   \n",
       "4     290583 166235 556025 217894 166235 556025 5589...   \n",
       "...                                                 ...   \n",
       "1995  195526 195526 195526 195526 1002121 36379 8135...   \n",
       "1996  288225 812720 500918 500918 698153 507072 5009...   \n",
       "1997  952981 502801 917988 917988 143799 667127 4004...   \n",
       "1998  771829 332521 332521 60522 60522 672487 711909...   \n",
       "1999  305283 990086 985582 741215 741215 741215 6061...   \n",
       "\n",
       "                                               cat_path  \\\n",
       "0     35 1554 1554 119 1554 662 1095 662 35 833 833 ...   \n",
       "1     1023 420 407 1505 962 602 184 1606 351 1505 11...   \n",
       "2     1188 646 1175 1188 1414 681 1175 681 681 115 1...   \n",
       "3     601 601 601 601 601 601 601 601 601 601 601 60...   \n",
       "4     601 601 601 601 601 601 601 601 601 601 601 60...   \n",
       "...                                                 ...   \n",
       "1995  384 384 384 384 1075 1075 1075 1349 1349 1349 ...   \n",
       "1996  35 681 295 295 1518 1518 295 1468 1518 1468 81...   \n",
       "1997  898 795 354 354 833 1150 843 898 898 898 898 8...   \n",
       "1998  1213 1075 1075 1213 1213 1656 1075 1213 1213 1...   \n",
       "1999  1271 1271 812 464 464 464 1577 464 464 464 464...   \n",
       "\n",
       "                                            seller_path  \\\n",
       "0     4811 4811 4811 1897 4811 3315 2925 1340 1875 4...   \n",
       "1     1435 1648 223 3178 2418 1614 3004 2511 2285 78...   \n",
       "2     805 390 4252 3979 1228 2029 2029 2029 4252 923...   \n",
       "3     3139 3139 3524 3139 3139 3524 3139 3139 3139 3...   \n",
       "4     3139 3139 3524 3139 3139 3524 3139 3139 3139 3...   \n",
       "...                                                 ...   \n",
       "1995  4696 4696 4696 4696 494 3863 4741 1251 2269 12...   \n",
       "1996  696 899 3398 3398 3398 3398 3398 3398 3398 339...   \n",
       "1997  3319 390 1338 1338 3149 3319 1338 3319 3319 33...   \n",
       "1998  2588 3168 3168 2160 2160 2439 3168 2160 2588 4...   \n",
       "1999  1500 540 1849 176 176 176 3028 176 176 176 176...   \n",
       "\n",
       "                                             brand_path  \\\n",
       "0     127.0 127.0 127.0 4704.0 127.0 1605.0 6000.0 1...   \n",
       "1     5504.0 7780.0 1751.0 7540.0 6652.0 8116.0 5328...   \n",
       "2     1842.0 5920.0 133.0 6304.0 7584.0 133.0 133.0 ...   \n",
       "3     549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....   \n",
       "4     549.0 549.0 549.0 549.0 549.0 549.0 549.0 549....   \n",
       "...                                                 ...   \n",
       "1995  6548.0 6548.0 6548.0 6548.0 7288.0 2960.0 7088...   \n",
       "1996  3600.0 6568.0 30.0 30.0 30.0 30.0 30.0 30.0 30...   \n",
       "1997  5508.0 6876.0 4740.0 4740.0 5388.0 1283.0 4740...   \n",
       "1998  2760.0 4504.0 4504.0 1195.0 1195.0 1307.0 4504...   \n",
       "1999  7284.0 5384.0 5576.0 6664.0 6664.0 6664.0 4608...   \n",
       "\n",
       "                                        time_stamp_path  ... action_type_1  \\\n",
       "0     518 518 518 520 520 524 524 524 525 525 525 52...  ...             0   \n",
       "1     517 520 522 522 527 530 530 530 601 601 602 60...  ...             0   \n",
       "2     517 604 604 604 607 609 609 609 609 615 621 62...  ...             0   \n",
       "3     924 924 924 924 924 924 924 924 924 924 924 92...  ...             0   \n",
       "4     924 924 924 924 924 924 924 924 924 924 924 92...  ...             0   \n",
       "...                                                 ...  ...           ...   \n",
       "1995  610 610 610 630 707 707 707 1109 1109 1109 110...  ...             0   \n",
       "1996  524 528 530 530 530 530 530 530 530 530 705 70...  ...             0   \n",
       "1997  515 516 517 517 604 606 606 619 619 619 619 61...  ...             0   \n",
       "1998  531 531 531 531 531 531 531 531 531 531 531 53...  ...             0   \n",
       "1999  511 511 514 520 520 520 520 520 520 520 520 52...  ...             0   \n",
       "\n",
       "      seller_most_1_cnt  cat_most_1_cnt  brand_most_1_cnt  action_type_1_cnt  \\\n",
       "0                    35              43                35                299   \n",
       "1                     9              56                11                259   \n",
       "2                    93              29                48                241   \n",
       "3                    45              68                45                228   \n",
       "4                    45              68                45                228   \n",
       "...                 ...             ...               ...                ...   \n",
       "1995                 11              11                11                 32   \n",
       "1996                 67              32                66                264   \n",
       "1997                 15              12                12                 74   \n",
       "1998                 16              21                17                 84   \n",
       "1999                 55              22                28                189   \n",
       "\n",
       "      user_cnt_0  user_cnt_1  user_cnt_2  user_cnt_3  seller_nunique_0  \n",
       "0            310         310         310         310                97  \n",
       "1            274         274         274         274               181  \n",
       "2            278         278         278         278                56  \n",
       "3            237         237         237         237                50  \n",
       "4            237         237         237         237                50  \n",
       "...          ...         ...         ...         ...               ...  \n",
       "1995          35          35          35          35                14  \n",
       "1996         284         284         284         284                52  \n",
       "1997          84          84          84          84                30  \n",
       "1998          92          92          92          92                39  \n",
       "1999         210         210         210         210                46  \n",
       "\n",
       "[2000 rows x 35 columns]"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_data_test"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 组合特征\n",
    "\n",
    "### 特征组合进行业务特征提取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 点击次数\n",
    "all_data_test = user_col_cnt(all_data_test,  ['seller_path', 'item_path'], '0', 'user_cnt_0')\n",
    "\n",
    "# 不同店铺个数\n",
    "all_data_test = user_col_nunique(all_data_test,  ['seller_path', 'item_path'], '0', 'seller_nunique_0')\n",
    "# ...."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 查看提取的特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['user_id', 'merchant_id', 'label', 'age_range', 'gender', 'item_path',\n",
       "       'cat_path', 'seller_path', 'brand_path', 'time_stamp_path',\n",
       "       'action_type_path', 'user_cnt', 'seller_nunique', 'cat_nunique',\n",
       "       'brand_nunique', 'item_nunique', 'time_stamp_nunique',\n",
       "       'action_type_nunique', 'time_stamp_max', 'time_stamp_min',\n",
       "       'time_stamp_std', 'time_stamp_range', 'seller_most_1', 'cat_most_1',\n",
       "       'brand_most_1', 'action_type_1', 'seller_most_1_cnt', 'cat_most_1_cnt',\n",
       "       'brand_most_1_cnt', 'action_type_1_cnt', 'user_cnt_0', 'user_cnt_1',\n",
       "       'user_cnt_2', 'user_cnt_3', 'seller_nunique_0'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 190,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_data_test.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['user_id',\n",
       " 'merchant_id',\n",
       " 'label',\n",
       " 'age_range',\n",
       " 'gender',\n",
       " 'item_path',\n",
       " 'cat_path',\n",
       " 'seller_path',\n",
       " 'brand_path',\n",
       " 'time_stamp_path',\n",
       " 'action_type_path',\n",
       " 'user_cnt',\n",
       " 'seller_nunique',\n",
       " 'cat_nunique',\n",
       " 'brand_nunique',\n",
       " 'item_nunique',\n",
       " 'time_stamp_nunique',\n",
       " 'action_type_nunique',\n",
       " 'time_stamp_max',\n",
       " 'time_stamp_min',\n",
       " 'time_stamp_std',\n",
       " 'time_stamp_range',\n",
       " 'seller_most_1',\n",
       " 'cat_most_1',\n",
       " 'brand_most_1',\n",
       " 'action_type_1',\n",
       " 'seller_most_1_cnt',\n",
       " 'cat_most_1_cnt',\n",
       " 'brand_most_1_cnt',\n",
       " 'action_type_1_cnt',\n",
       " 'user_cnt_0',\n",
       " 'user_cnt_1',\n",
       " 'user_cnt_2',\n",
       " 'user_cnt_3',\n",
       " 'seller_nunique_0']"
      ]
     },
     "execution_count": 191,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(all_data_test.columns)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 利用countvector，tfidf提取特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "-- 知识点四\n",
    "-- 利用countvector，tfidf提取特征\n",
    "\"\"\"\n",
    "from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer, ENGLISH_STOP_WORDS\n",
    "from scipy import sparse\n",
    "# cntVec = CountVectorizer(stop_words=ENGLISH_STOP_WORDS, ngram_range=(1, 1), max_features=100)\n",
    "tfidfVec = TfidfVectorizer(stop_words=ENGLISH_STOP_WORDS, ngram_range=(1, 1), max_features=100)\n",
    "\n",
    "\n",
    "# columns_list = ['seller_path', 'cat_path', 'brand_path', 'action_type_path', 'item_path', 'time_stamp_path']\n",
    "columns_list = ['seller_path']\n",
    "for i, col in enumerate(columns_list):\n",
    "    all_data_test[col] = all_data_test[col].astype(str)\n",
    "    tfidfVec.fit(all_data_test[col])\n",
    "    data_ = tfidfVec.transform(all_data_test[col])\n",
    "    if i == 0:\n",
    "        data_cat = data_\n",
    "    else:\n",
    "        data_cat = sparse.hstack((data_cat, data_))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 特征重命名 特征合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_tfidf = pd.DataFrame(data_cat.toarray())\n",
    "df_tfidf.columns = ['tfidf_' + str(i) for i in df_tfidf.columns]\n",
    "all_data_test = pd.concat([all_data_test, df_tfidf],axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## embeeding特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "metadata": {},
   "outputs": [],
   "source": [
    "import gensim\n",
    "\n",
    "# Train Word2Vec model\n",
    "\n",
    "model = gensim.models.Word2Vec(all_data_test['seller_path'].apply(lambda x: x.split(' ')), size=100, window=5, min_count=5, workers=4)\n",
    "# model.save(\"product2vec.model\")\n",
    "# model = gensim.models.Word2Vec.load(\"product2vec.model\")\n",
    "\n",
    "def mean_w2v_(x, model, size=100):\n",
    "    try:\n",
    "        i = 0\n",
    "        for word in x.split(' '):\n",
    "            if word in model.wv.vocab:\n",
    "                i += 1\n",
    "                if i == 1:\n",
    "                    vec = np.zeros(size)\n",
    "                vec += model.wv[word]\n",
    "        return vec / i \n",
    "    except:\n",
    "        return  np.zeros(size)\n",
    "\n",
    "\n",
    "def get_mean_w2v(df_data, columns, model, size):\n",
    "    data_array = []\n",
    "    for index, row in df_data.iterrows():\n",
    "        w2v = mean_w2v_(row[columns], model, size)\n",
    "        data_array.append(w2v)\n",
    "    return pd.DataFrame(data_array)\n",
    "\n",
    "df_embeeding = get_mean_w2v(all_data_test, 'seller_path', model, 100)\n",
    "df_embeeding.columns = ['embeeding_' + str(i) for i in df_embeeding.columns]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### embeeding特征和原始特征合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_data_test = pd.concat([all_data_test, df_embeeding],axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## stacking特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "-- 知识点六\n",
    "-- stacking特征\n",
    "\"\"\"\n",
    "# from sklearn.cross_validation import KFold\n",
    "from sklearn.model_selection import KFold\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from scipy import sparse\n",
    "import xgboost\n",
    "import lightgbm\n",
    "from sklearn.ensemble import RandomForestClassifier,AdaBoostClassifier,GradientBoostingClassifier,ExtraTreesClassifier\n",
    "from sklearn.ensemble import RandomForestRegressor,AdaBoostRegressor,GradientBoostingRegressor,ExtraTreesRegressor\n",
    "from sklearn.linear_model import LinearRegression,LogisticRegression\n",
    "from sklearn.svm import LinearSVC,SVC\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "from sklearn.metrics import log_loss,mean_absolute_error,mean_squared_error\n",
    "from sklearn.naive_bayes import MultinomialNB,GaussianNB"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### stacking 回归特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "-- 回归\n",
    "-- stacking 回归特征\n",
    "\"\"\"\n",
    "def stacking_reg(clf,train_x,train_y,test_x,clf_name,kf,label_split=None):\n",
    "    train=np.zeros((train_x.shape[0],1))\n",
    "    test=np.zeros((test_x.shape[0],1))\n",
    "    test_pre=np.empty((folds,test_x.shape[0],1))\n",
    "    cv_scores=[]\n",
    "    for i,(train_index,test_index) in enumerate(kf.split(train_x,label_split)):       \n",
    "        tr_x=train_x[train_index]\n",
    "        tr_y=train_y[train_index]\n",
    "        te_x=train_x[test_index]\n",
    "        te_y = train_y[test_index]\n",
    "        if clf_name in [\"rf\",\"ada\",\"gb\",\"et\",\"lr\"]:\n",
    "            clf.fit(tr_x,tr_y)\n",
    "            pre=clf.predict(te_x).reshape(-1,1)\n",
    "            train[test_index]=pre\n",
    "            test_pre[i,:]=clf.predict(test_x).reshape(-1,1)\n",
    "            cv_scores.append(mean_squared_error(te_y, pre))\n",
    "        elif clf_name in [\"xgb\"]:\n",
    "            train_matrix = clf.DMatrix(tr_x, label=tr_y, missing=-1)\n",
    "            test_matrix = clf.DMatrix(te_x, label=te_y, missing=-1)\n",
    "            z = clf.DMatrix(test_x, label=te_y, missing=-1)\n",
    "            params = {'booster': 'gbtree',\n",
    "                      'eval_metric': 'rmse',\n",
    "                      'gamma': 1,\n",
    "                      'min_child_weight': 1.5,\n",
    "                      'max_depth': 5,\n",
    "                      'lambda': 10,\n",
    "                      'subsample': 0.7,\n",
    "                      'colsample_bytree': 0.7,\n",
    "                      'colsample_bylevel': 0.7,\n",
    "                      'eta': 0.03,\n",
    "                      'tree_method': 'exact',\n",
    "                      'seed': 2017,\n",
    "                      'nthread': 12\n",
    "                      }\n",
    "            num_round = 10000\n",
    "            early_stopping_rounds = 100\n",
    "            watchlist = [(train_matrix, 'train'),\n",
    "                         (test_matrix, 'eval')\n",
    "                         ]\n",
    "            if test_matrix:\n",
    "                model = clf.train(params, train_matrix, num_boost_round=num_round,evals=watchlist,\n",
    "                                  early_stopping_rounds=early_stopping_rounds\n",
    "                                  )\n",
    "                pre= model.predict(test_matrix,ntree_limit=model.best_ntree_limit).reshape(-1,1)\n",
    "                train[test_index]=pre\n",
    "                test_pre[i, :]= model.predict(z, ntree_limit=model.best_ntree_limit).reshape(-1,1)\n",
    "                cv_scores.append(mean_squared_error(te_y, pre))\n",
    "\n",
    "        elif clf_name in [\"lgb\"]:\n",
    "            train_matrix = clf.Dataset(tr_x, label=tr_y)\n",
    "            test_matrix = clf.Dataset(te_x, label=te_y)\n",
    "            params = {\n",
    "                      'boosting_type': 'gbdt',\n",
    "                      'objective': 'regression_l2',\n",
    "                      'metric': 'mse',\n",
    "                      'min_child_weight': 1.5,\n",
    "                      'num_leaves': 2**5,\n",
    "                      'lambda_l2': 10,\n",
    "                      'subsample': 0.7,\n",
    "                      'colsample_bytree': 0.7,\n",
    "                      'colsample_bylevel': 0.7,\n",
    "                      'learning_rate': 0.03,\n",
    "                      'tree_method': 'exact',\n",
    "                      'seed': 2017,\n",
    "                      'nthread': 12,\n",
    "                      'silent': True,\n",
    "                      }\n",
    "            num_round = 10000\n",
    "            early_stopping_rounds = 100\n",
    "            if test_matrix:\n",
    "                model = clf.train(params, train_matrix,num_round,valid_sets=test_matrix,\n",
    "                                  early_stopping_rounds=early_stopping_rounds\n",
    "                                  )\n",
    "                pre= model.predict(te_x,num_iteration=model.best_iteration).reshape(-1,1)\n",
    "                train[test_index]=pre\n",
    "                test_pre[i, :]= model.predict(test_x, num_iteration=model.best_iteration).reshape(-1,1)\n",
    "                cv_scores.append(mean_squared_error(te_y, pre))\n",
    "        else:\n",
    "            raise IOError(\"Please add new clf.\")\n",
    "        print(\"%s now score is:\"%clf_name,cv_scores)\n",
    "    test[:]=test_pre.mean(axis=0)\n",
    "    print(\"%s_score_list:\"%clf_name,cv_scores)\n",
    "    print(\"%s_score_mean:\"%clf_name,np.mean(cv_scores))\n",
    "    return train.reshape(-1,1),test.reshape(-1,1)\n",
    "\n",
    "def rf_reg(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    randomforest = RandomForestRegressor(n_estimators=600, max_depth=20, n_jobs=-1, random_state=2017, max_features=\"auto\",verbose=1)\n",
    "    rf_train, rf_test = stacking_reg(randomforest, x_train, y_train, x_valid, \"rf\", kf, label_split=label_split)\n",
    "    return rf_train, rf_test,\"rf_reg\"\n",
    "\n",
    "def ada_reg(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    adaboost = AdaBoostRegressor(n_estimators=30, random_state=2017, learning_rate=0.01)\n",
    "    ada_train, ada_test = stacking_reg(adaboost, x_train, y_train, x_valid, \"ada\", kf, label_split=label_split)\n",
    "    return ada_train, ada_test,\"ada_reg\"\n",
    "\n",
    "def gb_reg(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    gbdt = GradientBoostingRegressor(learning_rate=0.04, n_estimators=100, subsample=0.8, random_state=2017,max_depth=5,verbose=1)\n",
    "    gbdt_train, gbdt_test = stacking_reg(gbdt, x_train, y_train, x_valid, \"gb\", kf, label_split=label_split)\n",
    "    return gbdt_train, gbdt_test,\"gb_reg\"\n",
    "\n",
    "def et_reg(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    extratree = ExtraTreesRegressor(n_estimators=600, max_depth=35, max_features=\"auto\", n_jobs=-1, random_state=2017,verbose=1)\n",
    "    et_train, et_test = stacking_reg(extratree, x_train, y_train, x_valid, \"et\", kf, label_split=label_split)\n",
    "    return et_train, et_test,\"et_reg\"\n",
    "\n",
    "def lr_reg(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    lr_reg=LinearRegression(n_jobs=-1)\n",
    "    lr_train, lr_test = stacking_reg(lr_reg, x_train, y_train, x_valid, \"lr\", kf, label_split=label_split)\n",
    "    return lr_train, lr_test, \"lr_reg\"\n",
    "\n",
    "def xgb_reg(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    xgb_train, xgb_test = stacking_reg(xgboost, x_train, y_train, x_valid, \"xgb\", kf, label_split=label_split)\n",
    "    return xgb_train, xgb_test,\"xgb_reg\"\n",
    "\n",
    "def lgb_reg(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    lgb_train, lgb_test = stacking_reg(lightgbm, x_train, y_train, x_valid, \"lgb\", kf, label_split=label_split)\n",
    "    return lgb_train, lgb_test,\"lgb_reg\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### stacking 分类特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "-- 分类\n",
    "-- stacking 分类特征\n",
    "\"\"\"\n",
    "def stacking_clf(clf,train_x,train_y,test_x,clf_name,kf,label_split=None):\n",
    "    train=np.zeros((train_x.shape[0],1))\n",
    "    test=np.zeros((test_x.shape[0],1))\n",
    "    test_pre=np.empty((folds,test_x.shape[0],1))\n",
    "    cv_scores=[]\n",
    "    for i,(train_index,test_index) in enumerate(kf.split(train_x,label_split)):       \n",
    "        tr_x=train_x[train_index]\n",
    "        tr_y=train_y[train_index]\n",
    "        te_x=train_x[test_index]\n",
    "        te_y = train_y[test_index]\n",
    "\n",
    "        if clf_name in [\"rf\",\"ada\",\"gb\",\"et\",\"lr\",\"knn\",\"gnb\"]:\n",
    "            clf.fit(tr_x,tr_y)\n",
    "            pre=clf.predict_proba(te_x)\n",
    "            \n",
    "            train[test_index]=pre[:,0].reshape(-1,1)\n",
    "            test_pre[i,:]=clf.predict_proba(test_x)[:,0].reshape(-1,1)\n",
    "            \n",
    "            cv_scores.append(log_loss(te_y, pre[:,0].reshape(-1,1)))\n",
    "        elif clf_name in [\"xgb\"]:\n",
    "            train_matrix = clf.DMatrix(tr_x, label=tr_y, missing=-1)\n",
    "            test_matrix = clf.DMatrix(te_x, label=te_y, missing=-1)\n",
    "            z = clf.DMatrix(test_x)\n",
    "            params = {'booster': 'gbtree',\n",
    "                      'objective': 'multi:softprob',\n",
    "                      'eval_metric': 'mlogloss',\n",
    "                      'gamma': 1,\n",
    "                      'min_child_weight': 1.5,\n",
    "                      'max_depth': 5,\n",
    "                      'lambda': 10,\n",
    "                      'subsample': 0.7,\n",
    "                      'colsample_bytree': 0.7,\n",
    "                      'colsample_bylevel': 0.7,\n",
    "                      'eta': 0.03,\n",
    "                      'tree_method': 'exact',\n",
    "                      'seed': 2017,\n",
    "                      \"num_class\": 2\n",
    "                      }\n",
    "\n",
    "            num_round = 10000\n",
    "            early_stopping_rounds = 100\n",
    "            watchlist = [(train_matrix, 'train'),\n",
    "                         (test_matrix, 'eval')\n",
    "                         ]\n",
    "            if test_matrix:\n",
    "                model = clf.train(params, train_matrix, num_boost_round=num_round,evals=watchlist,\n",
    "                                  early_stopping_rounds=early_stopping_rounds\n",
    "                                  )\n",
    "                pre= model.predict(test_matrix,ntree_limit=model.best_ntree_limit)\n",
    "                train[test_index]=pre[:,0].reshape(-1,1)\n",
    "                test_pre[i, :]= model.predict(z, ntree_limit=model.best_ntree_limit)[:,0].reshape(-1,1)\n",
    "                cv_scores.append(log_loss(te_y, pre[:,0].reshape(-1,1)))\n",
    "        elif clf_name in [\"lgb\"]:\n",
    "            train_matrix = clf.Dataset(tr_x, label=tr_y)\n",
    "            test_matrix = clf.Dataset(te_x, label=te_y)\n",
    "            params = {\n",
    "                      'boosting_type': 'gbdt',\n",
    "                      #'boosting_type': 'dart',\n",
    "                      'objective': 'multiclass',\n",
    "                      'metric': 'multi_logloss',\n",
    "                      'min_child_weight': 1.5,\n",
    "                      'num_leaves': 2**5,\n",
    "                      'lambda_l2': 10,\n",
    "                      'subsample': 0.7,\n",
    "                      'colsample_bytree': 0.7,\n",
    "                      'colsample_bylevel': 0.7,\n",
    "                      'learning_rate': 0.03,\n",
    "                      'tree_method': 'exact',\n",
    "                      'seed': 2017,\n",
    "                      \"num_class\": 2,\n",
    "                      'silent': True,\n",
    "                      }\n",
    "            num_round = 10000\n",
    "            early_stopping_rounds = 100\n",
    "            if test_matrix:\n",
    "                model = clf.train(params, train_matrix,num_round,valid_sets=test_matrix,\n",
    "                                  early_stopping_rounds=early_stopping_rounds\n",
    "                                  )\n",
    "                pre= model.predict(te_x,num_iteration=model.best_iteration)\n",
    "                train[test_index]=pre[:,0].reshape(-1,1)\n",
    "                test_pre[i, :]= model.predict(test_x, num_iteration=model.best_iteration)[:,0].reshape(-1,1)\n",
    "                cv_scores.append(log_loss(te_y, pre[:,0].reshape(-1,1)))\n",
    "        else:\n",
    "            raise IOError(\"Please add new clf.\")\n",
    "        print(\"%s now score is:\"%clf_name,cv_scores)\n",
    "    test[:]=test_pre.mean(axis=0)\n",
    "    print(\"%s_score_list:\"%clf_name,cv_scores)\n",
    "    print(\"%s_score_mean:\"%clf_name,np.mean(cv_scores))\n",
    "    return train.reshape(-1,1),test.reshape(-1,1)\n",
    "\n",
    "def rf_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    randomforest = RandomForestClassifier(n_estimators=1200, max_depth=20, n_jobs=-1, random_state=2017, max_features=\"auto\",verbose=1)\n",
    "    rf_train, rf_test = stacking_clf(randomforest, x_train, y_train, x_valid, \"rf\", kf, label_split=label_split)\n",
    "    return rf_train, rf_test,\"rf\"\n",
    "\n",
    "def ada_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    adaboost = AdaBoostClassifier(n_estimators=50, random_state=2017, learning_rate=0.01)\n",
    "    ada_train, ada_test = stacking_clf(adaboost, x_train, y_train, x_valid, \"ada\", kf, label_split=label_split)\n",
    "    return ada_train, ada_test,\"ada\"\n",
    "\n",
    "def gb_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    gbdt = GradientBoostingClassifier(learning_rate=0.04, n_estimators=100, subsample=0.8, random_state=2017,max_depth=5,verbose=1)\n",
    "    gbdt_train, gbdt_test = stacking_clf(gbdt, x_train, y_train, x_valid, \"gb\", kf, label_split=label_split)\n",
    "    return gbdt_train, gbdt_test,\"gb\"\n",
    "\n",
    "def et_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    extratree = ExtraTreesClassifier(n_estimators=1200, max_depth=35, max_features=\"auto\", n_jobs=-1, random_state=2017,verbose=1)\n",
    "    et_train, et_test = stacking_clf(extratree, x_train, y_train, x_valid, \"et\", kf, label_split=label_split)\n",
    "    return et_train, et_test,\"et\"\n",
    "\n",
    "def xgb_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    xgb_train, xgb_test = stacking_clf(xgboost, x_train, y_train, x_valid, \"xgb\", kf, label_split=label_split)\n",
    "    return xgb_train, xgb_test,\"xgb\"\n",
    "\n",
    "def lgb_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    xgb_train, xgb_test = stacking_clf(lightgbm, x_train, y_train, x_valid, \"lgb\", kf, label_split=label_split)\n",
    "    return xgb_train, xgb_test,\"lgb\"\n",
    "\n",
    "def gnb_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    gnb=GaussianNB()\n",
    "    gnb_train, gnb_test = stacking_clf(gnb, x_train, y_train, x_valid, \"gnb\", kf, label_split=label_split)\n",
    "    return gnb_train, gnb_test,\"gnb\"\n",
    "\n",
    "def lr_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    logisticregression=LogisticRegression(n_jobs=-1,random_state=2017,C=0.1,max_iter=200)\n",
    "    lr_train, lr_test = stacking_clf(logisticregression, x_train, y_train, x_valid, \"lr\", kf, label_split=label_split)\n",
    "    return lr_train, lr_test, \"lr\"\n",
    "\n",
    "def knn_clf(x_train, y_train, x_valid, kf, label_split=None):\n",
    "    kneighbors=KNeighborsClassifier(n_neighbors=200,n_jobs=-1)\n",
    "    knn_train, knn_test = stacking_clf(kneighbors, x_train, y_train, x_valid, \"lr\", kf, label_split=label_split)\n",
    "    return knn_train, knn_test, \"knn\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 获取训练和验证数据(为stacking特征做准备)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "metadata": {},
   "outputs": [],
   "source": [
    "features_columns = [c for c in all_data_test.columns if c not in ['label', 'prob', 'seller_path', 'cat_path', 'brand_path', 'action_type_path', 'item_path', 'time_stamp_path']]\n",
    "x_train = all_data_test[~all_data_test['label'].isna()][features_columns].values\n",
    "y_train = all_data_test[~all_data_test['label'].isna()]['label'].values\n",
    "x_valid = all_data_test[all_data_test['label'].isna()][features_columns].values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 处理函数值inf以及nan情况"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_matrix(data):\n",
    "    where_are_nan = np.isnan(data)\n",
    "    where_are_inf = np.isinf(data)\n",
    "    data[where_are_nan] = 0\n",
    "    data[where_are_inf] = 0\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_train = np.float_(get_matrix(np.float_(x_train)))\n",
    "y_train = np.int_(y_train)\n",
    "x_valid = x_train"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 导入划分数据函数 设stacking特征为5折"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import StratifiedKFold, KFold\n",
    "folds = 5\n",
    "seed = 1\n",
    "kf = KFold(n_splits=5, shuffle=True, random_state=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 使用lgb和xgb分类模型构造stacking特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 203,
   "metadata": {},
   "outputs": [],
   "source": [
    "# clf_list = [lgb_clf, xgb_clf, lgb_reg, xgb_reg]\n",
    "# clf_list_col = ['lgb_clf', 'xgb_clf', 'lgb_reg', 'xgb_reg']\n",
    "\n",
    "clf_list = [lgb_clf, xgb_clf]\n",
    "clf_list_col = ['lgb_clf', 'xgb_clf']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 训练模型，获取stacking特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.003222 seconds.\n",
      "You can set `force_row_wise=true` to remove the overhead.\n",
      "And if memory is not enough, you can set `force_col_wise=true`.\n",
      "[LightGBM] [Info] Total Bins 32649\n",
      "[LightGBM] [Info] Number of data points in the train set: 1600, number of used features: 227\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Info] Start training from score -0.065873\n",
      "[LightGBM] [Info] Start training from score -2.752786\n",
      "[1]\tvalid_0's multi_logloss: 0.294621\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[2]\tvalid_0's multi_logloss: 0.294957\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[3]\tvalid_0's multi_logloss: 0.29504\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[4]\tvalid_0's multi_logloss: 0.295335\n",
      "[5]\tvalid_0's multi_logloss: 0.295676\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[6]\tvalid_0's multi_logloss: 0.296057\n",
      "[7]\tvalid_0's multi_logloss: 0.296504\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[8]\tvalid_0's multi_logloss: 0.296545\n",
      "[9]\tvalid_0's multi_logloss: 0.297045\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[10]\tvalid_0's multi_logloss: 0.297513\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[11]\tvalid_0's multi_logloss: 0.297589\n",
      "[12]\tvalid_0's multi_logloss: 0.298058\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[13]\tvalid_0's multi_logloss: 0.298346\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[14]\tvalid_0's multi_logloss: 0.29852\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[15]\tvalid_0's multi_logloss: 0.299103\n",
      "[16]\tvalid_0's multi_logloss: 0.299417\n",
      "[17]\tvalid_0's multi_logloss: 0.299339\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[18]\tvalid_0's multi_logloss: 0.29949\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[19]\tvalid_0's multi_logloss: 0.299463\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[20]\tvalid_0's multi_logloss: 0.299519\n",
      "[21]\tvalid_0's multi_logloss: 0.299703\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[22]\tvalid_0's multi_logloss: 0.300115\n",
      "[23]\tvalid_0's multi_logloss: 0.300495\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[24]\tvalid_0's multi_logloss: 0.300604\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[25]\tvalid_0's multi_logloss: 0.300874\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[26]\tvalid_0's multi_logloss: 0.301198\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[27]\tvalid_0's multi_logloss: 0.301455\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[28]\tvalid_0's multi_logloss: 0.301554\n",
      "[29]\tvalid_0's multi_logloss: 0.301858\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[30]\tvalid_0's multi_logloss: 0.302248\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[31]\tvalid_0's multi_logloss: 0.302665\n",
      "[32]\tvalid_0's multi_logloss: 0.30293\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[33]\tvalid_0's multi_logloss: 0.303284\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[34]\tvalid_0's multi_logloss: 0.303562\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[35]\tvalid_0's multi_logloss: 0.303823\n",
      "[36]\tvalid_0's multi_logloss: 0.30414\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[37]\tvalid_0's multi_logloss: 0.304259\n",
      "[38]\tvalid_0's multi_logloss: 0.304264\n",
      "[39]\tvalid_0's multi_logloss: 0.304579\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[40]\tvalid_0's multi_logloss: 0.304524\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[41]\tvalid_0's multi_logloss: 0.304736\n",
      "[42]\tvalid_0's multi_logloss: 0.304979\n",
      "[43]\tvalid_0's multi_logloss: 0.30532\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[44]\tvalid_0's multi_logloss: 0.305383\n",
      "[45]\tvalid_0's multi_logloss: 0.305696\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[46]\tvalid_0's multi_logloss: 0.306048\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[47]\tvalid_0's multi_logloss: 0.306475\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[48]\tvalid_0's multi_logloss: 0.306616\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[49]\tvalid_0's multi_logloss: 0.306955\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[50]\tvalid_0's multi_logloss: 0.307209\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[51]\tvalid_0's multi_logloss: 0.307533\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[52]\tvalid_0's multi_logloss: 0.30801\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[53]\tvalid_0's multi_logloss: 0.308485\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[54]\tvalid_0's multi_logloss: 0.308842\n",
      "[55]\tvalid_0's multi_logloss: 0.309215\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[56]\tvalid_0's multi_logloss: 0.309494\n",
      "[57]\tvalid_0's multi_logloss: 0.30994\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[58]\tvalid_0's multi_logloss: 0.310387\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[59]\tvalid_0's multi_logloss: 0.310628\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[60]\tvalid_0's multi_logloss: 0.310831\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[61]\tvalid_0's multi_logloss: 0.311412\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[62]\tvalid_0's multi_logloss: 0.311853\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[63]\tvalid_0's multi_logloss: 0.312476\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[64]\tvalid_0's multi_logloss: 0.312882\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[65]\tvalid_0's multi_logloss: 0.313025\n",
      "[66]\tvalid_0's multi_logloss: 0.31344\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[67]\tvalid_0's multi_logloss: 0.313919\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[68]\tvalid_0's multi_logloss: 0.314476\n",
      "[69]\tvalid_0's multi_logloss: 0.315042\n",
      "[70]\tvalid_0's multi_logloss: 0.315384\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[71]\tvalid_0's multi_logloss: 0.315761\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[72]\tvalid_0's multi_logloss: 0.316066\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[73]\tvalid_0's multi_logloss: 0.316391\n",
      "[74]\tvalid_0's multi_logloss: 0.316524\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[75]\tvalid_0's multi_logloss: 0.317246\n",
      "[76]\tvalid_0's multi_logloss: 0.317732\n",
      "[77]\tvalid_0's multi_logloss: 0.317782\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[78]\tvalid_0's multi_logloss: 0.318438\n",
      "[79]\tvalid_0's multi_logloss: 0.318916\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[80]\tvalid_0's multi_logloss: 0.31924\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[81]\tvalid_0's multi_logloss: 0.319673\n",
      "[82]\tvalid_0's multi_logloss: 0.320022\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[83]\tvalid_0's multi_logloss: 0.320578\n",
      "[84]\tvalid_0's multi_logloss: 0.321119\n",
      "[85]\tvalid_0's multi_logloss: 0.321308\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[86]\tvalid_0's multi_logloss: 0.32177\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[87]\tvalid_0's multi_logloss: 0.322187\n",
      "[88]\tvalid_0's multi_logloss: 0.322506\n",
      "[89]\tvalid_0's multi_logloss: 0.322893\n",
      "[90]\tvalid_0's multi_logloss: 0.323383\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[91]\tvalid_0's multi_logloss: 0.32374\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[92]\tvalid_0's multi_logloss: 0.324396\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[93]\tvalid_0's multi_logloss: 0.325021\n",
      "[94]\tvalid_0's multi_logloss: 0.325483\n",
      "[95]\tvalid_0's multi_logloss: 0.325908\n",
      "[96]\tvalid_0's multi_logloss: 0.326451\n",
      "[97]\tvalid_0's multi_logloss: 0.326906\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[98]\tvalid_0's multi_logloss: 0.327295\n",
      "[99]\tvalid_0's multi_logloss: 0.32765\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[100]\tvalid_0's multi_logloss: 0.328047\n",
      "[101]\tvalid_0's multi_logloss: 0.328456\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's multi_logloss: 0.294621\n",
      "lgb now score is: [2.5286925489677774]\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.017853 seconds.\n",
      "You can set `force_row_wise=true` to remove the overhead.\n",
      "And if memory is not enough, you can set `force_col_wise=true`.\n",
      "[LightGBM] [Info] Total Bins 32688\n",
      "[LightGBM] [Info] Number of data points in the train set: 1600, number of used features: 227\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Info] Start training from score -0.073243\n",
      "[LightGBM] [Info] Start training from score -2.650371\n",
      "[1]\tvalid_0's multi_logloss: 0.221094\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[2]\tvalid_0's multi_logloss: 0.220988\n",
      "[3]\tvalid_0's multi_logloss: 0.221066\n",
      "[4]\tvalid_0's multi_logloss: 0.220621\n",
      "[5]\tvalid_0's multi_logloss: 0.220761\n",
      "[6]\tvalid_0's multi_logloss: 0.220515\n",
      "[7]\tvalid_0's multi_logloss: 0.220646\n",
      "[8]\tvalid_0's multi_logloss: 0.220712\n",
      "[9]\tvalid_0's multi_logloss: 0.221067\n",
      "[10]\tvalid_0's multi_logloss: 0.221447\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[11]\tvalid_0's multi_logloss: 0.221465\n",
      "[12]\tvalid_0's multi_logloss: 0.22133\n",
      "[13]\tvalid_0's multi_logloss: 0.221269\n",
      "[14]\tvalid_0's multi_logloss: 0.221253\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[15]\tvalid_0's multi_logloss: 0.221162\n",
      "[16]\tvalid_0's multi_logloss: 0.221465\n",
      "[17]\tvalid_0's multi_logloss: 0.221751\n",
      "[18]\tvalid_0's multi_logloss: 0.222035\n",
      "[19]\tvalid_0's multi_logloss: 0.222155\n",
      "[20]\tvalid_0's multi_logloss: 0.222097\n",
      "[21]\tvalid_0's multi_logloss: 0.222232\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[22]\tvalid_0's multi_logloss: 0.222083\n",
      "[23]\tvalid_0's multi_logloss: 0.222287\n",
      "[24]\tvalid_0's multi_logloss: 0.222611\n",
      "[25]\tvalid_0's multi_logloss: 0.222767\n",
      "[26]\tvalid_0's multi_logloss: 0.222883\n",
      "[27]\tvalid_0's multi_logloss: 0.222971\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[28]\tvalid_0's multi_logloss: 0.22336\n",
      "[29]\tvalid_0's multi_logloss: 0.223872\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[30]\tvalid_0's multi_logloss: 0.224032\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[31]\tvalid_0's multi_logloss: 0.224257\n",
      "[32]\tvalid_0's multi_logloss: 0.224465\n",
      "[33]\tvalid_0's multi_logloss: 0.224648\n",
      "[34]\tvalid_0's multi_logloss: 0.225207\n",
      "[35]\tvalid_0's multi_logloss: 0.225415\n",
      "[36]\tvalid_0's multi_logloss: 0.225721\n",
      "[37]\tvalid_0's multi_logloss: 0.22603\n",
      "[38]\tvalid_0's multi_logloss: 0.225975\n",
      "[39]\tvalid_0's multi_logloss: 0.22632\n",
      "[40]\tvalid_0's multi_logloss: 0.226783\n",
      "[41]\tvalid_0's multi_logloss: 0.227048\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[42]\tvalid_0's multi_logloss: 0.227138\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[43]\tvalid_0's multi_logloss: 0.227153\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[44]\tvalid_0's multi_logloss: 0.227263\n",
      "[45]\tvalid_0's multi_logloss: 0.227499\n",
      "[46]\tvalid_0's multi_logloss: 0.227705\n",
      "[47]\tvalid_0's multi_logloss: 0.228016\n",
      "[48]\tvalid_0's multi_logloss: 0.228227\n",
      "[49]\tvalid_0's multi_logloss: 0.228272\n",
      "[50]\tvalid_0's multi_logloss: 0.228549\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[51]\tvalid_0's multi_logloss: 0.228746\n",
      "[52]\tvalid_0's multi_logloss: 0.229097\n",
      "[53]\tvalid_0's multi_logloss: 0.229395\n",
      "[54]\tvalid_0's multi_logloss: 0.229349\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[55]\tvalid_0's multi_logloss: 0.229643\n",
      "[56]\tvalid_0's multi_logloss: 0.230139\n",
      "[57]\tvalid_0's multi_logloss: 0.23067\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[58]\tvalid_0's multi_logloss: 0.230948\n",
      "[59]\tvalid_0's multi_logloss: 0.231437\n",
      "[60]\tvalid_0's multi_logloss: 0.231811\n",
      "[61]\tvalid_0's multi_logloss: 0.231941\n",
      "[62]\tvalid_0's multi_logloss: 0.232107\n",
      "[63]\tvalid_0's multi_logloss: 0.232208\n",
      "[64]\tvalid_0's multi_logloss: 0.232577\n",
      "[65]\tvalid_0's multi_logloss: 0.233064\n",
      "[66]\tvalid_0's multi_logloss: 0.233429\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[67]\tvalid_0's multi_logloss: 0.233833\n",
      "[68]\tvalid_0's multi_logloss: 0.23417\n",
      "[69]\tvalid_0's multi_logloss: 0.234454\n",
      "[70]\tvalid_0's multi_logloss: 0.234835\n",
      "[71]\tvalid_0's multi_logloss: 0.235015\n",
      "[72]\tvalid_0's multi_logloss: 0.235372\n",
      "[73]\tvalid_0's multi_logloss: 0.235521\n",
      "[74]\tvalid_0's multi_logloss: 0.235792\n",
      "[75]\tvalid_0's multi_logloss: 0.23618\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[76]\tvalid_0's multi_logloss: 0.236429\n",
      "[77]\tvalid_0's multi_logloss: 0.23621\n",
      "[78]\tvalid_0's multi_logloss: 0.236571\n",
      "[79]\tvalid_0's multi_logloss: 0.236569\n",
      "[80]\tvalid_0's multi_logloss: 0.236902\n",
      "[81]\tvalid_0's multi_logloss: 0.237267\n",
      "[82]\tvalid_0's multi_logloss: 0.237397\n",
      "[83]\tvalid_0's multi_logloss: 0.237687\n",
      "[84]\tvalid_0's multi_logloss: 0.237847\n",
      "[85]\tvalid_0's multi_logloss: 0.238089\n",
      "[86]\tvalid_0's multi_logloss: 0.238198\n",
      "[87]\tvalid_0's multi_logloss: 0.238659\n",
      "[88]\tvalid_0's multi_logloss: 0.238983\n",
      "[89]\tvalid_0's multi_logloss: 0.239264\n",
      "[90]\tvalid_0's multi_logloss: 0.239416\n",
      "[91]\tvalid_0's multi_logloss: 0.239674\n",
      "[92]\tvalid_0's multi_logloss: 0.239937\n",
      "[93]\tvalid_0's multi_logloss: 0.24021\n",
      "[94]\tvalid_0's multi_logloss: 0.240641\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[95]\tvalid_0's multi_logloss: 0.241002\n",
      "[96]\tvalid_0's multi_logloss: 0.241419\n",
      "[97]\tvalid_0's multi_logloss: 0.241723\n",
      "[98]\tvalid_0's multi_logloss: 0.241964\n",
      "[99]\tvalid_0's multi_logloss: 0.242316\n",
      "[100]\tvalid_0's multi_logloss: 0.242518\n",
      "[101]\tvalid_0's multi_logloss: 0.242887\n",
      "[102]\tvalid_0's multi_logloss: 0.243173\n",
      "[103]\tvalid_0's multi_logloss: 0.243382\n",
      "[104]\tvalid_0's multi_logloss: 0.24357\n",
      "[105]\tvalid_0's multi_logloss: 0.244041\n",
      "[106]\tvalid_0's multi_logloss: 0.244408\n",
      "Early stopping, best iteration is:\n",
      "[6]\tvalid_0's multi_logloss: 0.220515\n",
      "lgb now score is: [2.5286925489677774, 2.5267151168788122]\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Auto-choosing col-wise multi-threading, the overhead of testing was 0.018809 seconds.\n",
      "You can set `force_col_wise=true` to remove the overhead.\n",
      "[LightGBM] [Info] Total Bins 32666\n",
      "[LightGBM] [Info] Number of data points in the train set: 1600, number of used features: 227\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Info] Start training from score -0.073243\n",
      "[LightGBM] [Info] Start training from score -2.650371\n",
      "[1]\tvalid_0's multi_logloss: 0.221463\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[2]\tvalid_0's multi_logloss: 0.221782\n",
      "[3]\tvalid_0's multi_logloss: 0.221883\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[4]\tvalid_0's multi_logloss: 0.222094\n",
      "[5]\tvalid_0's multi_logloss: 0.222284\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[6]\tvalid_0's multi_logloss: 0.222392\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[7]\tvalid_0's multi_logloss: 0.222377\n",
      "[8]\tvalid_0's multi_logloss: 0.222337\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[9]\tvalid_0's multi_logloss: 0.222491\n",
      "[10]\tvalid_0's multi_logloss: 0.222859\n",
      "[11]\tvalid_0's multi_logloss: 0.223339\n",
      "[12]\tvalid_0's multi_logloss: 0.223643\n",
      "[13]\tvalid_0's multi_logloss: 0.223879\n",
      "[14]\tvalid_0's multi_logloss: 0.224562\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[15]\tvalid_0's multi_logloss: 0.22485\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[16]\tvalid_0's multi_logloss: 0.225234\n",
      "[17]\tvalid_0's multi_logloss: 0.225611\n",
      "[18]\tvalid_0's multi_logloss: 0.225919\n",
      "[19]\tvalid_0's multi_logloss: 0.226364\n",
      "[20]\tvalid_0's multi_logloss: 0.226411\n",
      "[21]\tvalid_0's multi_logloss: 0.226774\n",
      "[22]\tvalid_0's multi_logloss: 0.227097\n",
      "[23]\tvalid_0's multi_logloss: 0.227527\n",
      "[24]\tvalid_0's multi_logloss: 0.228038\n",
      "[25]\tvalid_0's multi_logloss: 0.228363\n",
      "[26]\tvalid_0's multi_logloss: 0.228457\n",
      "[27]\tvalid_0's multi_logloss: 0.228685\n",
      "[28]\tvalid_0's multi_logloss: 0.228829\n",
      "[29]\tvalid_0's multi_logloss: 0.229179\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[30]\tvalid_0's multi_logloss: 0.229345\n",
      "[31]\tvalid_0's multi_logloss: 0.229738\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[32]\tvalid_0's multi_logloss: 0.229937\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[33]\tvalid_0's multi_logloss: 0.230195\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[34]\tvalid_0's multi_logloss: 0.230462\n",
      "[35]\tvalid_0's multi_logloss: 0.230659\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[36]\tvalid_0's multi_logloss: 0.23121\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[37]\tvalid_0's multi_logloss: 0.231526\n",
      "[38]\tvalid_0's multi_logloss: 0.231514\n",
      "[39]\tvalid_0's multi_logloss: 0.231744\n",
      "[40]\tvalid_0's multi_logloss: 0.231932\n",
      "[41]\tvalid_0's multi_logloss: 0.2322\n",
      "[42]\tvalid_0's multi_logloss: 0.232615\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[43]\tvalid_0's multi_logloss: 0.232771\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[44]\tvalid_0's multi_logloss: 0.232813\n",
      "[45]\tvalid_0's multi_logloss: 0.233119\n",
      "[46]\tvalid_0's multi_logloss: 0.233231\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[47]\tvalid_0's multi_logloss: 0.233338\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[48]\tvalid_0's multi_logloss: 0.233507\n",
      "[49]\tvalid_0's multi_logloss: 0.233886\n",
      "[50]\tvalid_0's multi_logloss: 0.234059\n",
      "[51]\tvalid_0's multi_logloss: 0.234072\n",
      "[52]\tvalid_0's multi_logloss: 0.234427\n",
      "[53]\tvalid_0's multi_logloss: 0.234363\n",
      "[54]\tvalid_0's multi_logloss: 0.234554\n",
      "[55]\tvalid_0's multi_logloss: 0.235133\n",
      "[56]\tvalid_0's multi_logloss: 0.235221\n",
      "[57]\tvalid_0's multi_logloss: 0.235375\n",
      "[58]\tvalid_0's multi_logloss: 0.235773\n",
      "[59]\tvalid_0's multi_logloss: 0.235985\n",
      "[60]\tvalid_0's multi_logloss: 0.236237\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[61]\tvalid_0's multi_logloss: 0.236422\n",
      "[62]\tvalid_0's multi_logloss: 0.236702\n",
      "[63]\tvalid_0's multi_logloss: 0.237147\n",
      "[64]\tvalid_0's multi_logloss: 0.23691\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[65]\tvalid_0's multi_logloss: 0.236997\n",
      "[66]\tvalid_0's multi_logloss: 0.237392\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[67]\tvalid_0's multi_logloss: 0.237795\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[68]\tvalid_0's multi_logloss: 0.238149\n",
      "[69]\tvalid_0's multi_logloss: 0.238382\n",
      "[70]\tvalid_0's multi_logloss: 0.238507\n",
      "[71]\tvalid_0's multi_logloss: 0.238563\n",
      "[72]\tvalid_0's multi_logloss: 0.23879\n",
      "[73]\tvalid_0's multi_logloss: 0.23885\n",
      "[74]\tvalid_0's multi_logloss: 0.239251\n",
      "[75]\tvalid_0's multi_logloss: 0.23962\n",
      "[76]\tvalid_0's multi_logloss: 0.23998\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[77]\tvalid_0's multi_logloss: 0.240055\n",
      "[78]\tvalid_0's multi_logloss: 0.24033\n",
      "[79]\tvalid_0's multi_logloss: 0.240501\n",
      "[80]\tvalid_0's multi_logloss: 0.240882\n",
      "[81]\tvalid_0's multi_logloss: 0.241304\n",
      "[82]\tvalid_0's multi_logloss: 0.241639\n",
      "[83]\tvalid_0's multi_logloss: 0.241634\n",
      "[84]\tvalid_0's multi_logloss: 0.242041\n",
      "[85]\tvalid_0's multi_logloss: 0.242397\n",
      "[86]\tvalid_0's multi_logloss: 0.242639\n",
      "[87]\tvalid_0's multi_logloss: 0.243035\n",
      "[88]\tvalid_0's multi_logloss: 0.24311\n",
      "[89]\tvalid_0's multi_logloss: 0.2433\n",
      "[90]\tvalid_0's multi_logloss: 0.243466\n",
      "[91]\tvalid_0's multi_logloss: 0.244012\n",
      "[92]\tvalid_0's multi_logloss: 0.244244\n",
      "[93]\tvalid_0's multi_logloss: 0.244303\n",
      "[94]\tvalid_0's multi_logloss: 0.244485\n",
      "[95]\tvalid_0's multi_logloss: 0.244821\n",
      "[96]\tvalid_0's multi_logloss: 0.244922\n",
      "[97]\tvalid_0's multi_logloss: 0.245095\n",
      "[98]\tvalid_0's multi_logloss: 0.245443\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[99]\tvalid_0's multi_logloss: 0.245809\n",
      "[100]\tvalid_0's multi_logloss: 0.246363\n",
      "[101]\tvalid_0's multi_logloss: 0.246678\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's multi_logloss: 0.221463\n",
      "lgb now score is: [2.5286925489677774, 2.5267151168788122, 2.5072600478976628]\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Auto-choosing col-wise multi-threading, the overhead of testing was 0.022592 seconds.\n",
      "You can set `force_col_wise=true` to remove the overhead.\n",
      "[LightGBM] [Info] Total Bins 32589\n",
      "[LightGBM] [Info] Number of data points in the train set: 1600, number of used features: 226\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Info] Start training from score -0.065873\n",
      "[LightGBM] [Info] Start training from score -2.752786\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1]\tvalid_0's multi_logloss: 0.294629\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[2]\tvalid_0's multi_logloss: 0.294931\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[3]\tvalid_0's multi_logloss: 0.295118\n",
      "[4]\tvalid_0's multi_logloss: 0.295408\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[5]\tvalid_0's multi_logloss: 0.295666\n",
      "[6]\tvalid_0's multi_logloss: 0.295608\n",
      "[7]\tvalid_0's multi_logloss: 0.295987\n",
      "[8]\tvalid_0's multi_logloss: 0.296114\n",
      "[9]\tvalid_0's multi_logloss: 0.296176\n",
      "[10]\tvalid_0's multi_logloss: 0.296049\n",
      "[11]\tvalid_0's multi_logloss: 0.296462\n",
      "[12]\tvalid_0's multi_logloss: 0.296371\n",
      "[13]\tvalid_0's multi_logloss: 0.2965\n",
      "[14]\tvalid_0's multi_logloss: 0.296947\n",
      "[15]\tvalid_0's multi_logloss: 0.296943\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[16]\tvalid_0's multi_logloss: 0.296729\n",
      "[17]\tvalid_0's multi_logloss: 0.29723\n",
      "[18]\tvalid_0's multi_logloss: 0.297596\n",
      "[19]\tvalid_0's multi_logloss: 0.297579\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[20]\tvalid_0's multi_logloss: 0.297845\n",
      "[21]\tvalid_0's multi_logloss: 0.298269\n",
      "[22]\tvalid_0's multi_logloss: 0.298231\n",
      "[23]\tvalid_0's multi_logloss: 0.298184\n",
      "[24]\tvalid_0's multi_logloss: 0.298085\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[25]\tvalid_0's multi_logloss: 0.29824\n",
      "[26]\tvalid_0's multi_logloss: 0.298255\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[27]\tvalid_0's multi_logloss: 0.298482\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[28]\tvalid_0's multi_logloss: 0.298972\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[29]\tvalid_0's multi_logloss: 0.299296\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[30]\tvalid_0's multi_logloss: 0.299265\n",
      "[31]\tvalid_0's multi_logloss: 0.299447\n",
      "[32]\tvalid_0's multi_logloss: 0.299312\n",
      "[33]\tvalid_0's multi_logloss: 0.299581\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[34]\tvalid_0's multi_logloss: 0.299756\n",
      "[35]\tvalid_0's multi_logloss: 0.300031\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[36]\tvalid_0's multi_logloss: 0.300272\n",
      "[37]\tvalid_0's multi_logloss: 0.300427\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[38]\tvalid_0's multi_logloss: 0.30075\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[39]\tvalid_0's multi_logloss: 0.300994\n",
      "[40]\tvalid_0's multi_logloss: 0.301047\n",
      "[41]\tvalid_0's multi_logloss: 0.301302\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[42]\tvalid_0's multi_logloss: 0.301705\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[43]\tvalid_0's multi_logloss: 0.301598\n",
      "[44]\tvalid_0's multi_logloss: 0.301757\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[45]\tvalid_0's multi_logloss: 0.301668\n",
      "[46]\tvalid_0's multi_logloss: 0.302151\n",
      "[47]\tvalid_0's multi_logloss: 0.302184\n",
      "[48]\tvalid_0's multi_logloss: 0.302266\n",
      "[49]\tvalid_0's multi_logloss: 0.302576\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[50]\tvalid_0's multi_logloss: 0.302713\n",
      "[51]\tvalid_0's multi_logloss: 0.302815\n",
      "[52]\tvalid_0's multi_logloss: 0.302941\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[53]\tvalid_0's multi_logloss: 0.303045\n",
      "[54]\tvalid_0's multi_logloss: 0.3032\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[55]\tvalid_0's multi_logloss: 0.303367\n",
      "[56]\tvalid_0's multi_logloss: 0.303589\n",
      "[57]\tvalid_0's multi_logloss: 0.303748\n",
      "[58]\tvalid_0's multi_logloss: 0.303474\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[59]\tvalid_0's multi_logloss: 0.303607\n",
      "[60]\tvalid_0's multi_logloss: 0.303369\n",
      "[61]\tvalid_0's multi_logloss: 0.30368\n",
      "[62]\tvalid_0's multi_logloss: 0.303795\n",
      "[63]\tvalid_0's multi_logloss: 0.304062\n",
      "[64]\tvalid_0's multi_logloss: 0.304022\n",
      "[65]\tvalid_0's multi_logloss: 0.304159\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[66]\tvalid_0's multi_logloss: 0.3042\n",
      "[67]\tvalid_0's multi_logloss: 0.304531\n",
      "[68]\tvalid_0's multi_logloss: 0.304694\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[69]\tvalid_0's multi_logloss: 0.304879\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[70]\tvalid_0's multi_logloss: 0.304821\n",
      "[71]\tvalid_0's multi_logloss: 0.304969\n",
      "[72]\tvalid_0's multi_logloss: 0.305199\n",
      "[73]\tvalid_0's multi_logloss: 0.30549\n",
      "[74]\tvalid_0's multi_logloss: 0.305884\n",
      "[75]\tvalid_0's multi_logloss: 0.306125\n",
      "[76]\tvalid_0's multi_logloss: 0.306436\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[77]\tvalid_0's multi_logloss: 0.306598\n",
      "[78]\tvalid_0's multi_logloss: 0.307051\n",
      "[79]\tvalid_0's multi_logloss: 0.306988\n",
      "[80]\tvalid_0's multi_logloss: 0.306953\n",
      "[81]\tvalid_0's multi_logloss: 0.307282\n",
      "[82]\tvalid_0's multi_logloss: 0.307614\n",
      "[83]\tvalid_0's multi_logloss: 0.307994\n",
      "[84]\tvalid_0's multi_logloss: 0.30812\n",
      "[85]\tvalid_0's multi_logloss: 0.308325\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[86]\tvalid_0's multi_logloss: 0.308466\n",
      "[87]\tvalid_0's multi_logloss: 0.308852\n",
      "[88]\tvalid_0's multi_logloss: 0.309144\n",
      "[89]\tvalid_0's multi_logloss: 0.309407\n",
      "[90]\tvalid_0's multi_logloss: 0.309583\n",
      "[91]\tvalid_0's multi_logloss: 0.310041\n",
      "[92]\tvalid_0's multi_logloss: 0.31025\n",
      "[93]\tvalid_0's multi_logloss: 0.310683\n",
      "[94]\tvalid_0's multi_logloss: 0.310934\n",
      "[95]\tvalid_0's multi_logloss: 0.311238\n",
      "[96]\tvalid_0's multi_logloss: 0.311291\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[97]\tvalid_0's multi_logloss: 0.311734\n",
      "[98]\tvalid_0's multi_logloss: 0.311837\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[99]\tvalid_0's multi_logloss: 0.312093\n",
      "[100]\tvalid_0's multi_logloss: 0.312524\n",
      "[101]\tvalid_0's multi_logloss: 0.312865\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's multi_logloss: 0.294629\n",
      "lgb now score is: [2.5286925489677774, 2.5267151168788122, 2.5072600478976628, 2.5268742762533645]\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.006220 seconds.\n",
      "You can set `force_row_wise=true` to remove the overhead.\n",
      "And if memory is not enough, you can set `force_col_wise=true`.\n",
      "[LightGBM] [Info] Total Bins 32710\n",
      "[LightGBM] [Info] Number of data points in the train set: 1600, number of used features: 226\n",
      "[LightGBM] [Warning] Unknown parameter: colsample_bylevel\n",
      "[LightGBM] [Warning] Unknown parameter: tree_method\n",
      "[LightGBM] [Warning] Unknown parameter: silent\n",
      "[LightGBM] [Info] Start training from score -0.073916\n",
      "[LightGBM] [Info] Start training from score -2.641560\n",
      "[1]\tvalid_0's multi_logloss: 0.215241\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[2]\tvalid_0's multi_logloss: 0.215508\n",
      "[3]\tvalid_0's multi_logloss: 0.215621\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[4]\tvalid_0's multi_logloss: 0.215695\n",
      "[5]\tvalid_0's multi_logloss: 0.215637\n",
      "[6]\tvalid_0's multi_logloss: 0.215733\n",
      "[7]\tvalid_0's multi_logloss: 0.215631\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[8]\tvalid_0's multi_logloss: 0.21568\n",
      "[9]\tvalid_0's multi_logloss: 0.215923\n",
      "[10]\tvalid_0's multi_logloss: 0.215791\n",
      "[11]\tvalid_0's multi_logloss: 0.216091\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[12]\tvalid_0's multi_logloss: 0.216205\n",
      "[13]\tvalid_0's multi_logloss: 0.216241\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[14]\tvalid_0's multi_logloss: 0.216368\n",
      "[15]\tvalid_0's multi_logloss: 0.216453\n",
      "[16]\tvalid_0's multi_logloss: 0.216547\n",
      "[17]\tvalid_0's multi_logloss: 0.216687\n",
      "[18]\tvalid_0's multi_logloss: 0.216909\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[19]\tvalid_0's multi_logloss: 0.216883\n",
      "[20]\tvalid_0's multi_logloss: 0.217173\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[21]\tvalid_0's multi_logloss: 0.21746\n",
      "[22]\tvalid_0's multi_logloss: 0.217766\n",
      "[23]\tvalid_0's multi_logloss: 0.217892\n",
      "[24]\tvalid_0's multi_logloss: 0.217944\n",
      "[25]\tvalid_0's multi_logloss: 0.218138\n",
      "[26]\tvalid_0's multi_logloss: 0.218344\n",
      "[27]\tvalid_0's multi_logloss: 0.218475\n",
      "[28]\tvalid_0's multi_logloss: 0.218676\n",
      "[29]\tvalid_0's multi_logloss: 0.218972\n",
      "[30]\tvalid_0's multi_logloss: 0.21938\n",
      "[31]\tvalid_0's multi_logloss: 0.219565\n",
      "[32]\tvalid_0's multi_logloss: 0.219844\n",
      "[33]\tvalid_0's multi_logloss: 0.220155\n",
      "[34]\tvalid_0's multi_logloss: 0.22048\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[35]\tvalid_0's multi_logloss: 0.220831\n",
      "[36]\tvalid_0's multi_logloss: 0.221207\n",
      "[37]\tvalid_0's multi_logloss: 0.221462\n",
      "[38]\tvalid_0's multi_logloss: 0.221794\n",
      "[39]\tvalid_0's multi_logloss: 0.221775\n",
      "[40]\tvalid_0's multi_logloss: 0.222122\n",
      "[41]\tvalid_0's multi_logloss: 0.222287\n",
      "[42]\tvalid_0's multi_logloss: 0.222456\n",
      "[43]\tvalid_0's multi_logloss: 0.222473\n",
      "[44]\tvalid_0's multi_logloss: 0.222485\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[45]\tvalid_0's multi_logloss: 0.222767\n",
      "[46]\tvalid_0's multi_logloss: 0.22303\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[47]\tvalid_0's multi_logloss: 0.22324\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[48]\tvalid_0's multi_logloss: 0.223179\n",
      "[49]\tvalid_0's multi_logloss: 0.223144\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[50]\tvalid_0's multi_logloss: 0.223202\n",
      "[51]\tvalid_0's multi_logloss: 0.223328\n",
      "[52]\tvalid_0's multi_logloss: 0.223658\n",
      "[53]\tvalid_0's multi_logloss: 0.223925\n",
      "[54]\tvalid_0's multi_logloss: 0.224247\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[55]\tvalid_0's multi_logloss: 0.224436\n",
      "[56]\tvalid_0's multi_logloss: 0.224487\n",
      "[57]\tvalid_0's multi_logloss: 0.224479\n",
      "[58]\tvalid_0's multi_logloss: 0.224493\n",
      "[59]\tvalid_0's multi_logloss: 0.224833\n",
      "[60]\tvalid_0's multi_logloss: 0.22471\n",
      "[61]\tvalid_0's multi_logloss: 0.224895\n",
      "[62]\tvalid_0's multi_logloss: 0.225108\n",
      "[63]\tvalid_0's multi_logloss: 0.225275\n",
      "[64]\tvalid_0's multi_logloss: 0.225597\n",
      "[65]\tvalid_0's multi_logloss: 0.225841\n",
      "[66]\tvalid_0's multi_logloss: 0.226112\n",
      "[67]\tvalid_0's multi_logloss: 0.226324\n",
      "[68]\tvalid_0's multi_logloss: 0.226277\n",
      "[69]\tvalid_0's multi_logloss: 0.22662\n",
      "[70]\tvalid_0's multi_logloss: 0.226837\n",
      "[71]\tvalid_0's multi_logloss: 0.227238\n",
      "[72]\tvalid_0's multi_logloss: 0.22729\n",
      "[73]\tvalid_0's multi_logloss: 0.22768\n",
      "[74]\tvalid_0's multi_logloss: 0.228119\n",
      "[75]\tvalid_0's multi_logloss: 0.22842\n",
      "[76]\tvalid_0's multi_logloss: 0.228608\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[77]\tvalid_0's multi_logloss: 0.229203\n",
      "[78]\tvalid_0's multi_logloss: 0.229366\n",
      "[79]\tvalid_0's multi_logloss: 0.229671\n",
      "[80]\tvalid_0's multi_logloss: 0.230025\n",
      "[81]\tvalid_0's multi_logloss: 0.230406\n",
      "[82]\tvalid_0's multi_logloss: 0.230744\n",
      "[83]\tvalid_0's multi_logloss: 0.230863\n",
      "[84]\tvalid_0's multi_logloss: 0.231254\n",
      "[85]\tvalid_0's multi_logloss: 0.231303\n",
      "[86]\tvalid_0's multi_logloss: 0.231347\n",
      "[87]\tvalid_0's multi_logloss: 0.231469\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[88]\tvalid_0's multi_logloss: 0.231807\n",
      "[89]\tvalid_0's multi_logloss: 0.232071\n",
      "[90]\tvalid_0's multi_logloss: 0.232209\n",
      "[91]\tvalid_0's multi_logloss: 0.232531\n",
      "[92]\tvalid_0's multi_logloss: 0.232971\n",
      "[93]\tvalid_0's multi_logloss: 0.233153\n",
      "[94]\tvalid_0's multi_logloss: 0.233352\n",
      "[LightGBM] [Warning] No further splits with positive gain, best gain: -inf\n",
      "[95]\tvalid_0's multi_logloss: 0.233456\n",
      "[96]\tvalid_0's multi_logloss: 0.233664\n",
      "[97]\tvalid_0's multi_logloss: 0.234092\n",
      "[98]\tvalid_0's multi_logloss: 0.234267\n",
      "[99]\tvalid_0's multi_logloss: 0.234523\n",
      "[100]\tvalid_0's multi_logloss: 0.23457\n",
      "[101]\tvalid_0's multi_logloss: 0.234758\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's multi_logloss: 0.215241\n",
      "lgb now score is: [2.5286925489677774, 2.5267151168788122, 2.5072600478976628, 2.5268742762533645, 2.5034782587366324]\n",
      "lgb_score_list: [2.5286925489677774, 2.5267151168788122, 2.5072600478976628, 2.5268742762533645, 2.5034782587366324]\n",
      "lgb_score_mean: 2.5186040497468496\n",
      "[0]\ttrain-mlogloss:0.67068\teval-mlogloss:0.67258\n",
      "Multiple eval metrics have been passed: 'eval-mlogloss' will be used for early stopping.\n",
      "\n",
      "Will train until eval-mlogloss hasn't improved in 100 rounds.\n",
      "[1]\ttrain-mlogloss:0.64965\teval-mlogloss:0.65294\n",
      "[2]\ttrain-mlogloss:0.62935\teval-mlogloss:0.63456\n",
      "[3]\ttrain-mlogloss:0.61049\teval-mlogloss:0.61724\n",
      "[4]\ttrain-mlogloss:0.59259\teval-mlogloss:0.60084\n",
      "[5]\ttrain-mlogloss:0.57556\teval-mlogloss:0.58479\n",
      "[6]\ttrain-mlogloss:0.55942\teval-mlogloss:0.56978\n",
      "[7]\ttrain-mlogloss:0.54414\teval-mlogloss:0.55579\n",
      "[8]\ttrain-mlogloss:0.52970\teval-mlogloss:0.54258\n",
      "[9]\ttrain-mlogloss:0.51586\teval-mlogloss:0.53014\n",
      "[10]\ttrain-mlogloss:0.50262\teval-mlogloss:0.51812\n",
      "[11]\ttrain-mlogloss:0.49036\teval-mlogloss:0.50695\n",
      "[12]\ttrain-mlogloss:0.47842\teval-mlogloss:0.49615\n",
      "[13]\ttrain-mlogloss:0.46703\teval-mlogloss:0.48588\n",
      "[14]\ttrain-mlogloss:0.45630\teval-mlogloss:0.47630\n",
      "[15]\ttrain-mlogloss:0.44592\teval-mlogloss:0.46695\n",
      "[16]\ttrain-mlogloss:0.43608\teval-mlogloss:0.45830\n",
      "[17]\ttrain-mlogloss:0.42677\teval-mlogloss:0.45015\n",
      "[18]\ttrain-mlogloss:0.41762\teval-mlogloss:0.44206\n",
      "[19]\ttrain-mlogloss:0.40899\teval-mlogloss:0.43455\n",
      "[20]\ttrain-mlogloss:0.40077\teval-mlogloss:0.42730\n",
      "[21]\ttrain-mlogloss:0.39257\teval-mlogloss:0.41996\n",
      "[22]\ttrain-mlogloss:0.38500\teval-mlogloss:0.41343\n",
      "[23]\ttrain-mlogloss:0.37762\teval-mlogloss:0.40725\n",
      "[24]\ttrain-mlogloss:0.37064\teval-mlogloss:0.40158\n",
      "[25]\ttrain-mlogloss:0.36383\teval-mlogloss:0.39570\n",
      "[26]\ttrain-mlogloss:0.35742\teval-mlogloss:0.39019\n",
      "[27]\ttrain-mlogloss:0.35134\teval-mlogloss:0.38518\n",
      "[28]\ttrain-mlogloss:0.34535\teval-mlogloss:0.38004\n",
      "[29]\ttrain-mlogloss:0.33966\teval-mlogloss:0.37530\n",
      "[30]\ttrain-mlogloss:0.33412\teval-mlogloss:0.37079\n",
      "[31]\ttrain-mlogloss:0.32897\teval-mlogloss:0.36667\n",
      "[32]\ttrain-mlogloss:0.32392\teval-mlogloss:0.36279\n",
      "[33]\ttrain-mlogloss:0.31913\teval-mlogloss:0.35920\n",
      "[34]\ttrain-mlogloss:0.31444\teval-mlogloss:0.35539\n",
      "[35]\ttrain-mlogloss:0.30995\teval-mlogloss:0.35182\n",
      "[36]\ttrain-mlogloss:0.30550\teval-mlogloss:0.34847\n",
      "[37]\ttrain-mlogloss:0.30137\teval-mlogloss:0.34543\n",
      "[38]\ttrain-mlogloss:0.29736\teval-mlogloss:0.34240\n",
      "[39]\ttrain-mlogloss:0.29368\teval-mlogloss:0.33942\n",
      "[40]\ttrain-mlogloss:0.29011\teval-mlogloss:0.33678\n",
      "[41]\ttrain-mlogloss:0.28657\teval-mlogloss:0.33406\n",
      "[42]\ttrain-mlogloss:0.28305\teval-mlogloss:0.33169\n",
      "[43]\ttrain-mlogloss:0.27983\teval-mlogloss:0.32926\n",
      "[44]\ttrain-mlogloss:0.27665\teval-mlogloss:0.32707\n",
      "[45]\ttrain-mlogloss:0.27357\teval-mlogloss:0.32506\n",
      "[46]\ttrain-mlogloss:0.27059\teval-mlogloss:0.32305\n",
      "[47]\ttrain-mlogloss:0.26771\teval-mlogloss:0.32119\n",
      "[48]\ttrain-mlogloss:0.26484\teval-mlogloss:0.31949\n",
      "[49]\ttrain-mlogloss:0.26208\teval-mlogloss:0.31750\n",
      "[50]\ttrain-mlogloss:0.25967\teval-mlogloss:0.31602\n",
      "[51]\ttrain-mlogloss:0.25716\teval-mlogloss:0.31446\n",
      "[52]\ttrain-mlogloss:0.25461\teval-mlogloss:0.31290\n",
      "[53]\ttrain-mlogloss:0.25231\teval-mlogloss:0.31155\n",
      "[54]\ttrain-mlogloss:0.25010\teval-mlogloss:0.31043\n",
      "[55]\ttrain-mlogloss:0.24785\teval-mlogloss:0.30936\n",
      "[56]\ttrain-mlogloss:0.24561\teval-mlogloss:0.30826\n",
      "[57]\ttrain-mlogloss:0.24354\teval-mlogloss:0.30719\n",
      "[58]\ttrain-mlogloss:0.24147\teval-mlogloss:0.30608\n",
      "[59]\ttrain-mlogloss:0.23929\teval-mlogloss:0.30495\n",
      "[60]\ttrain-mlogloss:0.23727\teval-mlogloss:0.30414\n",
      "[61]\ttrain-mlogloss:0.23551\teval-mlogloss:0.30323\n",
      "[62]\ttrain-mlogloss:0.23368\teval-mlogloss:0.30242\n",
      "[63]\ttrain-mlogloss:0.23169\teval-mlogloss:0.30164\n",
      "[64]\ttrain-mlogloss:0.23000\teval-mlogloss:0.30094\n",
      "[65]\ttrain-mlogloss:0.22838\teval-mlogloss:0.30029\n",
      "[66]\ttrain-mlogloss:0.22695\teval-mlogloss:0.29967\n",
      "[67]\ttrain-mlogloss:0.22518\teval-mlogloss:0.29875\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[68]\ttrain-mlogloss:0.22382\teval-mlogloss:0.29827\n",
      "[69]\ttrain-mlogloss:0.22227\teval-mlogloss:0.29804\n",
      "[70]\ttrain-mlogloss:0.22096\teval-mlogloss:0.29746\n",
      "[71]\ttrain-mlogloss:0.21974\teval-mlogloss:0.29695\n",
      "[72]\ttrain-mlogloss:0.21829\teval-mlogloss:0.29630\n",
      "[73]\ttrain-mlogloss:0.21688\teval-mlogloss:0.29588\n",
      "[74]\ttrain-mlogloss:0.21545\teval-mlogloss:0.29548\n",
      "[75]\ttrain-mlogloss:0.21411\teval-mlogloss:0.29518\n",
      "[76]\ttrain-mlogloss:0.21266\teval-mlogloss:0.29514\n",
      "[77]\ttrain-mlogloss:0.21124\teval-mlogloss:0.29494\n",
      "[78]\ttrain-mlogloss:0.20984\teval-mlogloss:0.29484\n",
      "[79]\ttrain-mlogloss:0.20852\teval-mlogloss:0.29451\n",
      "[80]\ttrain-mlogloss:0.20718\teval-mlogloss:0.29431\n",
      "[81]\ttrain-mlogloss:0.20608\teval-mlogloss:0.29415\n",
      "[82]\ttrain-mlogloss:0.20474\teval-mlogloss:0.29406\n",
      "[83]\ttrain-mlogloss:0.20356\teval-mlogloss:0.29368\n",
      "[84]\ttrain-mlogloss:0.20243\teval-mlogloss:0.29369\n",
      "[85]\ttrain-mlogloss:0.20122\teval-mlogloss:0.29360\n",
      "[86]\ttrain-mlogloss:0.20007\teval-mlogloss:0.29353\n",
      "[87]\ttrain-mlogloss:0.19904\teval-mlogloss:0.29346\n",
      "[88]\ttrain-mlogloss:0.19780\teval-mlogloss:0.29358\n",
      "[89]\ttrain-mlogloss:0.19669\teval-mlogloss:0.29365\n",
      "[90]\ttrain-mlogloss:0.19568\teval-mlogloss:0.29354\n",
      "[91]\ttrain-mlogloss:0.19459\teval-mlogloss:0.29346\n",
      "[92]\ttrain-mlogloss:0.19353\teval-mlogloss:0.29348\n",
      "[93]\ttrain-mlogloss:0.19255\teval-mlogloss:0.29330\n",
      "[94]\ttrain-mlogloss:0.19146\teval-mlogloss:0.29330\n",
      "[95]\ttrain-mlogloss:0.19039\teval-mlogloss:0.29338\n",
      "[96]\ttrain-mlogloss:0.18924\teval-mlogloss:0.29330\n",
      "[97]\ttrain-mlogloss:0.18824\teval-mlogloss:0.29347\n",
      "[98]\ttrain-mlogloss:0.18723\teval-mlogloss:0.29367\n",
      "[99]\ttrain-mlogloss:0.18636\teval-mlogloss:0.29339\n",
      "[100]\ttrain-mlogloss:0.18543\teval-mlogloss:0.29344\n",
      "[101]\ttrain-mlogloss:0.18449\teval-mlogloss:0.29347\n",
      "[102]\ttrain-mlogloss:0.18343\teval-mlogloss:0.29342\n",
      "[103]\ttrain-mlogloss:0.18229\teval-mlogloss:0.29365\n",
      "[104]\ttrain-mlogloss:0.18141\teval-mlogloss:0.29373\n",
      "[105]\ttrain-mlogloss:0.18060\teval-mlogloss:0.29384\n",
      "[106]\ttrain-mlogloss:0.17970\teval-mlogloss:0.29402\n",
      "[107]\ttrain-mlogloss:0.17915\teval-mlogloss:0.29426\n",
      "[108]\ttrain-mlogloss:0.17820\teval-mlogloss:0.29451\n",
      "[109]\ttrain-mlogloss:0.17732\teval-mlogloss:0.29476\n",
      "[110]\ttrain-mlogloss:0.17661\teval-mlogloss:0.29530\n",
      "[111]\ttrain-mlogloss:0.17573\teval-mlogloss:0.29572\n",
      "[112]\ttrain-mlogloss:0.17504\teval-mlogloss:0.29599\n",
      "[113]\ttrain-mlogloss:0.17433\teval-mlogloss:0.29620\n",
      "[114]\ttrain-mlogloss:0.17365\teval-mlogloss:0.29652\n",
      "[115]\ttrain-mlogloss:0.17283\teval-mlogloss:0.29657\n",
      "[116]\ttrain-mlogloss:0.17204\teval-mlogloss:0.29645\n",
      "[117]\ttrain-mlogloss:0.17130\teval-mlogloss:0.29671\n",
      "[118]\ttrain-mlogloss:0.17048\teval-mlogloss:0.29695\n",
      "[119]\ttrain-mlogloss:0.16969\teval-mlogloss:0.29725\n",
      "[120]\ttrain-mlogloss:0.16889\teval-mlogloss:0.29720\n",
      "[121]\ttrain-mlogloss:0.16806\teval-mlogloss:0.29769\n",
      "[122]\ttrain-mlogloss:0.16735\teval-mlogloss:0.29802\n",
      "[123]\ttrain-mlogloss:0.16666\teval-mlogloss:0.29844\n",
      "[124]\ttrain-mlogloss:0.16597\teval-mlogloss:0.29867\n",
      "[125]\ttrain-mlogloss:0.16526\teval-mlogloss:0.29884\n",
      "[126]\ttrain-mlogloss:0.16458\teval-mlogloss:0.29888\n",
      "[127]\ttrain-mlogloss:0.16394\teval-mlogloss:0.29861\n",
      "[128]\ttrain-mlogloss:0.16341\teval-mlogloss:0.29883\n",
      "[129]\ttrain-mlogloss:0.16279\teval-mlogloss:0.29905\n",
      "[130]\ttrain-mlogloss:0.16223\teval-mlogloss:0.29904\n",
      "[131]\ttrain-mlogloss:0.16168\teval-mlogloss:0.29915\n",
      "[132]\ttrain-mlogloss:0.16097\teval-mlogloss:0.29946\n",
      "[133]\ttrain-mlogloss:0.16025\teval-mlogloss:0.29974\n",
      "[134]\ttrain-mlogloss:0.15965\teval-mlogloss:0.29983\n",
      "[135]\ttrain-mlogloss:0.15898\teval-mlogloss:0.29976\n",
      "[136]\ttrain-mlogloss:0.15835\teval-mlogloss:0.29991\n",
      "[137]\ttrain-mlogloss:0.15772\teval-mlogloss:0.30026\n",
      "[138]\ttrain-mlogloss:0.15711\teval-mlogloss:0.30062\n",
      "[139]\ttrain-mlogloss:0.15662\teval-mlogloss:0.30060\n",
      "[140]\ttrain-mlogloss:0.15599\teval-mlogloss:0.30097\n",
      "[141]\ttrain-mlogloss:0.15536\teval-mlogloss:0.30081\n",
      "[142]\ttrain-mlogloss:0.15474\teval-mlogloss:0.30060\n",
      "[143]\ttrain-mlogloss:0.15406\teval-mlogloss:0.30107\n",
      "[144]\ttrain-mlogloss:0.15344\teval-mlogloss:0.30145\n",
      "[145]\ttrain-mlogloss:0.15296\teval-mlogloss:0.30157\n",
      "[146]\ttrain-mlogloss:0.15243\teval-mlogloss:0.30153\n",
      "[147]\ttrain-mlogloss:0.15185\teval-mlogloss:0.30184\n",
      "[148]\ttrain-mlogloss:0.15133\teval-mlogloss:0.30209\n",
      "[149]\ttrain-mlogloss:0.15071\teval-mlogloss:0.30241\n",
      "[150]\ttrain-mlogloss:0.15014\teval-mlogloss:0.30275\n",
      "[151]\ttrain-mlogloss:0.14956\teval-mlogloss:0.30288\n",
      "[152]\ttrain-mlogloss:0.14906\teval-mlogloss:0.30294\n",
      "[153]\ttrain-mlogloss:0.14836\teval-mlogloss:0.30361\n",
      "[154]\ttrain-mlogloss:0.14785\teval-mlogloss:0.30406\n",
      "[155]\ttrain-mlogloss:0.14739\teval-mlogloss:0.30445\n",
      "[156]\ttrain-mlogloss:0.14688\teval-mlogloss:0.30485\n",
      "[157]\ttrain-mlogloss:0.14633\teval-mlogloss:0.30510\n",
      "[158]\ttrain-mlogloss:0.14576\teval-mlogloss:0.30523\n",
      "[159]\ttrain-mlogloss:0.14516\teval-mlogloss:0.30560\n",
      "[160]\ttrain-mlogloss:0.14461\teval-mlogloss:0.30562\n",
      "[161]\ttrain-mlogloss:0.14402\teval-mlogloss:0.30562\n",
      "[162]\ttrain-mlogloss:0.14355\teval-mlogloss:0.30568\n",
      "[163]\ttrain-mlogloss:0.14305\teval-mlogloss:0.30606\n",
      "[164]\ttrain-mlogloss:0.14247\teval-mlogloss:0.30620\n",
      "[165]\ttrain-mlogloss:0.14201\teval-mlogloss:0.30661\n",
      "[166]\ttrain-mlogloss:0.14166\teval-mlogloss:0.30685\n",
      "[167]\ttrain-mlogloss:0.14111\teval-mlogloss:0.30752\n",
      "[168]\ttrain-mlogloss:0.14064\teval-mlogloss:0.30776\n",
      "[169]\ttrain-mlogloss:0.14010\teval-mlogloss:0.30795\n",
      "[170]\ttrain-mlogloss:0.13966\teval-mlogloss:0.30826\n",
      "[171]\ttrain-mlogloss:0.13923\teval-mlogloss:0.30841\n",
      "[172]\ttrain-mlogloss:0.13882\teval-mlogloss:0.30885\n",
      "[173]\ttrain-mlogloss:0.13834\teval-mlogloss:0.30901\n",
      "[174]\ttrain-mlogloss:0.13791\teval-mlogloss:0.30893\n",
      "[175]\ttrain-mlogloss:0.13737\teval-mlogloss:0.30919\n",
      "[176]\ttrain-mlogloss:0.13702\teval-mlogloss:0.30927\n",
      "[177]\ttrain-mlogloss:0.13664\teval-mlogloss:0.30937\n",
      "[178]\ttrain-mlogloss:0.13625\teval-mlogloss:0.30950\n",
      "[179]\ttrain-mlogloss:0.13584\teval-mlogloss:0.30944\n",
      "[180]\ttrain-mlogloss:0.13541\teval-mlogloss:0.30968\n",
      "[181]\ttrain-mlogloss:0.13493\teval-mlogloss:0.31005\n",
      "[182]\ttrain-mlogloss:0.13455\teval-mlogloss:0.31026\n",
      "[183]\ttrain-mlogloss:0.13405\teval-mlogloss:0.31069\n",
      "[184]\ttrain-mlogloss:0.13363\teval-mlogloss:0.31095\n",
      "[185]\ttrain-mlogloss:0.13321\teval-mlogloss:0.31124\n",
      "[186]\ttrain-mlogloss:0.13276\teval-mlogloss:0.31132\n",
      "[187]\ttrain-mlogloss:0.13233\teval-mlogloss:0.31169\n",
      "[188]\ttrain-mlogloss:0.13184\teval-mlogloss:0.31214\n",
      "[189]\ttrain-mlogloss:0.13153\teval-mlogloss:0.31226\n",
      "[190]\ttrain-mlogloss:0.13119\teval-mlogloss:0.31221\n",
      "[191]\ttrain-mlogloss:0.13075\teval-mlogloss:0.31261\n",
      "[192]\ttrain-mlogloss:0.13037\teval-mlogloss:0.31292\n",
      "[193]\ttrain-mlogloss:0.12999\teval-mlogloss:0.31326\n",
      "[194]\ttrain-mlogloss:0.12958\teval-mlogloss:0.31357\n",
      "[195]\ttrain-mlogloss:0.12910\teval-mlogloss:0.31382\n",
      "[196]\ttrain-mlogloss:0.12873\teval-mlogloss:0.31383\n",
      "Stopping. Best iteration:\n",
      "[96]\ttrain-mlogloss:0.18924\teval-mlogloss:0.29330\n",
      "\n",
      "xgb now score is: [2.2977992902230473]\n",
      "[0]\ttrain-mlogloss:0.67114\teval-mlogloss:0.67111\n",
      "Multiple eval metrics have been passed: 'eval-mlogloss' will be used for early stopping.\n",
      "\n",
      "Will train until eval-mlogloss hasn't improved in 100 rounds.\n",
      "[1]\ttrain-mlogloss:0.65071\teval-mlogloss:0.65036\n",
      "[2]\ttrain-mlogloss:0.63131\teval-mlogloss:0.63059\n",
      "[3]\ttrain-mlogloss:0.61294\teval-mlogloss:0.61231\n",
      "[4]\ttrain-mlogloss:0.59546\teval-mlogloss:0.59441\n",
      "[5]\ttrain-mlogloss:0.57904\teval-mlogloss:0.57801\n",
      "[6]\ttrain-mlogloss:0.56353\teval-mlogloss:0.56250\n",
      "[7]\ttrain-mlogloss:0.54874\teval-mlogloss:0.54777\n",
      "[8]\ttrain-mlogloss:0.53456\teval-mlogloss:0.53345\n",
      "[9]\ttrain-mlogloss:0.52104\teval-mlogloss:0.51973\n",
      "[10]\ttrain-mlogloss:0.50824\teval-mlogloss:0.50687\n",
      "[11]\ttrain-mlogloss:0.49608\teval-mlogloss:0.49453\n",
      "[12]\ttrain-mlogloss:0.48448\teval-mlogloss:0.48303\n",
      "[13]\ttrain-mlogloss:0.47353\teval-mlogloss:0.47204\n",
      "[14]\ttrain-mlogloss:0.46281\teval-mlogloss:0.46109\n",
      "[15]\ttrain-mlogloss:0.45286\teval-mlogloss:0.45104\n",
      "[16]\ttrain-mlogloss:0.44318\teval-mlogloss:0.44137\n",
      "[17]\ttrain-mlogloss:0.43388\teval-mlogloss:0.43236\n",
      "[18]\ttrain-mlogloss:0.42498\teval-mlogloss:0.42342\n",
      "[19]\ttrain-mlogloss:0.41663\teval-mlogloss:0.41531\n",
      "[20]\ttrain-mlogloss:0.40858\teval-mlogloss:0.40728\n",
      "[21]\ttrain-mlogloss:0.40083\teval-mlogloss:0.39927\n",
      "[22]\ttrain-mlogloss:0.39363\teval-mlogloss:0.39187\n",
      "[23]\ttrain-mlogloss:0.38665\teval-mlogloss:0.38469\n",
      "[24]\ttrain-mlogloss:0.37969\teval-mlogloss:0.37788\n",
      "[25]\ttrain-mlogloss:0.37335\teval-mlogloss:0.37147\n",
      "[26]\ttrain-mlogloss:0.36720\teval-mlogloss:0.36540\n",
      "[27]\ttrain-mlogloss:0.36128\teval-mlogloss:0.35955\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[28]\ttrain-mlogloss:0.35564\teval-mlogloss:0.35396\n",
      "[29]\ttrain-mlogloss:0.35022\teval-mlogloss:0.34857\n",
      "[30]\ttrain-mlogloss:0.34501\teval-mlogloss:0.34346\n",
      "[31]\ttrain-mlogloss:0.34003\teval-mlogloss:0.33847\n",
      "[32]\ttrain-mlogloss:0.33524\teval-mlogloss:0.33384\n",
      "[33]\ttrain-mlogloss:0.33058\teval-mlogloss:0.32926\n",
      "[34]\ttrain-mlogloss:0.32620\teval-mlogloss:0.32492\n",
      "[35]\ttrain-mlogloss:0.32188\teval-mlogloss:0.32060\n",
      "[36]\ttrain-mlogloss:0.31757\teval-mlogloss:0.31637\n",
      "[37]\ttrain-mlogloss:0.31338\teval-mlogloss:0.31237\n",
      "[38]\ttrain-mlogloss:0.30958\teval-mlogloss:0.30867\n",
      "[39]\ttrain-mlogloss:0.30587\teval-mlogloss:0.30502\n",
      "[40]\ttrain-mlogloss:0.30247\teval-mlogloss:0.30177\n",
      "[41]\ttrain-mlogloss:0.29904\teval-mlogloss:0.29856\n",
      "[42]\ttrain-mlogloss:0.29577\teval-mlogloss:0.29568\n",
      "[43]\ttrain-mlogloss:0.29256\teval-mlogloss:0.29271\n",
      "[44]\ttrain-mlogloss:0.28951\teval-mlogloss:0.28992\n",
      "[45]\ttrain-mlogloss:0.28656\teval-mlogloss:0.28714\n",
      "[46]\ttrain-mlogloss:0.28374\teval-mlogloss:0.28469\n",
      "[47]\ttrain-mlogloss:0.28097\teval-mlogloss:0.28190\n",
      "[48]\ttrain-mlogloss:0.27831\teval-mlogloss:0.27938\n",
      "[49]\ttrain-mlogloss:0.27565\teval-mlogloss:0.27710\n",
      "[50]\ttrain-mlogloss:0.27314\teval-mlogloss:0.27487\n",
      "[51]\ttrain-mlogloss:0.27079\teval-mlogloss:0.27261\n",
      "[52]\ttrain-mlogloss:0.26845\teval-mlogloss:0.27070\n",
      "[53]\ttrain-mlogloss:0.26606\teval-mlogloss:0.26894\n",
      "[54]\ttrain-mlogloss:0.26362\teval-mlogloss:0.26686\n",
      "[55]\ttrain-mlogloss:0.26142\teval-mlogloss:0.26505\n",
      "[56]\ttrain-mlogloss:0.25944\teval-mlogloss:0.26336\n",
      "[57]\ttrain-mlogloss:0.25738\teval-mlogloss:0.26174\n",
      "[58]\ttrain-mlogloss:0.25532\teval-mlogloss:0.26005\n",
      "[59]\ttrain-mlogloss:0.25346\teval-mlogloss:0.25850\n",
      "[60]\ttrain-mlogloss:0.25139\teval-mlogloss:0.25699\n",
      "[61]\ttrain-mlogloss:0.24942\teval-mlogloss:0.25538\n",
      "[62]\ttrain-mlogloss:0.24765\teval-mlogloss:0.25411\n",
      "[63]\ttrain-mlogloss:0.24604\teval-mlogloss:0.25257\n",
      "[64]\ttrain-mlogloss:0.24434\teval-mlogloss:0.25144\n",
      "[65]\ttrain-mlogloss:0.24266\teval-mlogloss:0.25029\n",
      "[66]\ttrain-mlogloss:0.24096\teval-mlogloss:0.24917\n",
      "[67]\ttrain-mlogloss:0.23931\teval-mlogloss:0.24804\n",
      "[68]\ttrain-mlogloss:0.23792\teval-mlogloss:0.24703\n",
      "[69]\ttrain-mlogloss:0.23643\teval-mlogloss:0.24590\n",
      "[70]\ttrain-mlogloss:0.23493\teval-mlogloss:0.24500\n",
      "[71]\ttrain-mlogloss:0.23352\teval-mlogloss:0.24427\n",
      "[72]\ttrain-mlogloss:0.23221\teval-mlogloss:0.24338\n",
      "[73]\ttrain-mlogloss:0.23076\teval-mlogloss:0.24257\n",
      "[74]\ttrain-mlogloss:0.22965\teval-mlogloss:0.24196\n",
      "[75]\ttrain-mlogloss:0.22824\teval-mlogloss:0.24114\n",
      "[76]\ttrain-mlogloss:0.22689\teval-mlogloss:0.24053\n",
      "[77]\ttrain-mlogloss:0.22544\teval-mlogloss:0.23989\n",
      "[78]\ttrain-mlogloss:0.22426\teval-mlogloss:0.23888\n",
      "[79]\ttrain-mlogloss:0.22289\teval-mlogloss:0.23850\n",
      "[80]\ttrain-mlogloss:0.22164\teval-mlogloss:0.23809\n",
      "[81]\ttrain-mlogloss:0.22045\teval-mlogloss:0.23769\n",
      "[82]\ttrain-mlogloss:0.21937\teval-mlogloss:0.23706\n",
      "[83]\ttrain-mlogloss:0.21825\teval-mlogloss:0.23642\n",
      "[84]\ttrain-mlogloss:0.21711\teval-mlogloss:0.23608\n",
      "[85]\ttrain-mlogloss:0.21574\teval-mlogloss:0.23575\n",
      "[86]\ttrain-mlogloss:0.21449\teval-mlogloss:0.23530\n",
      "[87]\ttrain-mlogloss:0.21347\teval-mlogloss:0.23471\n",
      "[88]\ttrain-mlogloss:0.21228\teval-mlogloss:0.23418\n",
      "[89]\ttrain-mlogloss:0.21100\teval-mlogloss:0.23377\n",
      "[90]\ttrain-mlogloss:0.20982\teval-mlogloss:0.23355\n",
      "[91]\ttrain-mlogloss:0.20874\teval-mlogloss:0.23317\n",
      "[92]\ttrain-mlogloss:0.20749\teval-mlogloss:0.23303\n",
      "[93]\ttrain-mlogloss:0.20657\teval-mlogloss:0.23284\n",
      "[94]\ttrain-mlogloss:0.20532\teval-mlogloss:0.23249\n",
      "[95]\ttrain-mlogloss:0.20422\teval-mlogloss:0.23222\n",
      "[96]\ttrain-mlogloss:0.20314\teval-mlogloss:0.23197\n",
      "[97]\ttrain-mlogloss:0.20210\teval-mlogloss:0.23176\n",
      "[98]\ttrain-mlogloss:0.20111\teval-mlogloss:0.23166\n",
      "[99]\ttrain-mlogloss:0.20025\teval-mlogloss:0.23145\n",
      "[100]\ttrain-mlogloss:0.19904\teval-mlogloss:0.23133\n",
      "[101]\ttrain-mlogloss:0.19822\teval-mlogloss:0.23117\n",
      "[102]\ttrain-mlogloss:0.19711\teval-mlogloss:0.23090\n",
      "[103]\ttrain-mlogloss:0.19622\teval-mlogloss:0.23072\n",
      "[104]\ttrain-mlogloss:0.19526\teval-mlogloss:0.23063\n",
      "[105]\ttrain-mlogloss:0.19436\teval-mlogloss:0.23064\n",
      "[106]\ttrain-mlogloss:0.19325\teval-mlogloss:0.23069\n",
      "[107]\ttrain-mlogloss:0.19245\teval-mlogloss:0.23027\n",
      "[108]\ttrain-mlogloss:0.19147\teval-mlogloss:0.23018\n",
      "[109]\ttrain-mlogloss:0.19058\teval-mlogloss:0.22992\n",
      "[110]\ttrain-mlogloss:0.18976\teval-mlogloss:0.22987\n",
      "[111]\ttrain-mlogloss:0.18892\teval-mlogloss:0.22972\n",
      "[112]\ttrain-mlogloss:0.18810\teval-mlogloss:0.22981\n",
      "[113]\ttrain-mlogloss:0.18725\teval-mlogloss:0.22961\n",
      "[114]\ttrain-mlogloss:0.18642\teval-mlogloss:0.22957\n",
      "[115]\ttrain-mlogloss:0.18566\teval-mlogloss:0.22974\n",
      "[116]\ttrain-mlogloss:0.18471\teval-mlogloss:0.22993\n",
      "[117]\ttrain-mlogloss:0.18385\teval-mlogloss:0.22998\n",
      "[118]\ttrain-mlogloss:0.18313\teval-mlogloss:0.22992\n",
      "[119]\ttrain-mlogloss:0.18223\teval-mlogloss:0.22969\n",
      "[120]\ttrain-mlogloss:0.18139\teval-mlogloss:0.22991\n",
      "[121]\ttrain-mlogloss:0.18051\teval-mlogloss:0.22968\n",
      "[122]\ttrain-mlogloss:0.17952\teval-mlogloss:0.22990\n",
      "[123]\ttrain-mlogloss:0.17874\teval-mlogloss:0.23002\n",
      "[124]\ttrain-mlogloss:0.17796\teval-mlogloss:0.23005\n",
      "[125]\ttrain-mlogloss:0.17698\teval-mlogloss:0.23018\n",
      "[126]\ttrain-mlogloss:0.17618\teval-mlogloss:0.23027\n",
      "[127]\ttrain-mlogloss:0.17533\teval-mlogloss:0.23047\n",
      "[128]\ttrain-mlogloss:0.17455\teval-mlogloss:0.23064\n",
      "[129]\ttrain-mlogloss:0.17365\teval-mlogloss:0.23049\n",
      "[130]\ttrain-mlogloss:0.17300\teval-mlogloss:0.23060\n",
      "[131]\ttrain-mlogloss:0.17219\teval-mlogloss:0.23073\n",
      "[132]\ttrain-mlogloss:0.17149\teval-mlogloss:0.23073\n",
      "[133]\ttrain-mlogloss:0.17087\teval-mlogloss:0.23076\n",
      "[134]\ttrain-mlogloss:0.17011\teval-mlogloss:0.23090\n",
      "[135]\ttrain-mlogloss:0.16941\teval-mlogloss:0.23085\n",
      "[136]\ttrain-mlogloss:0.16874\teval-mlogloss:0.23098\n",
      "[137]\ttrain-mlogloss:0.16808\teval-mlogloss:0.23111\n",
      "[138]\ttrain-mlogloss:0.16751\teval-mlogloss:0.23108\n",
      "[139]\ttrain-mlogloss:0.16686\teval-mlogloss:0.23134\n",
      "[140]\ttrain-mlogloss:0.16618\teval-mlogloss:0.23141\n",
      "[141]\ttrain-mlogloss:0.16549\teval-mlogloss:0.23152\n",
      "[142]\ttrain-mlogloss:0.16492\teval-mlogloss:0.23152\n",
      "[143]\ttrain-mlogloss:0.16410\teval-mlogloss:0.23159\n",
      "[144]\ttrain-mlogloss:0.16343\teval-mlogloss:0.23158\n",
      "[145]\ttrain-mlogloss:0.16289\teval-mlogloss:0.23177\n",
      "[146]\ttrain-mlogloss:0.16227\teval-mlogloss:0.23184\n",
      "[147]\ttrain-mlogloss:0.16160\teval-mlogloss:0.23193\n",
      "[148]\ttrain-mlogloss:0.16107\teval-mlogloss:0.23174\n",
      "[149]\ttrain-mlogloss:0.16035\teval-mlogloss:0.23201\n",
      "[150]\ttrain-mlogloss:0.15965\teval-mlogloss:0.23198\n",
      "[151]\ttrain-mlogloss:0.15893\teval-mlogloss:0.23197\n",
      "[152]\ttrain-mlogloss:0.15832\teval-mlogloss:0.23213\n",
      "[153]\ttrain-mlogloss:0.15773\teval-mlogloss:0.23205\n",
      "[154]\ttrain-mlogloss:0.15710\teval-mlogloss:0.23194\n",
      "[155]\ttrain-mlogloss:0.15668\teval-mlogloss:0.23195\n",
      "[156]\ttrain-mlogloss:0.15616\teval-mlogloss:0.23212\n",
      "[157]\ttrain-mlogloss:0.15561\teval-mlogloss:0.23248\n",
      "[158]\ttrain-mlogloss:0.15499\teval-mlogloss:0.23240\n",
      "[159]\ttrain-mlogloss:0.15452\teval-mlogloss:0.23253\n",
      "[160]\ttrain-mlogloss:0.15398\teval-mlogloss:0.23262\n",
      "[161]\ttrain-mlogloss:0.15335\teval-mlogloss:0.23284\n",
      "[162]\ttrain-mlogloss:0.15291\teval-mlogloss:0.23297\n",
      "[163]\ttrain-mlogloss:0.15228\teval-mlogloss:0.23322\n",
      "[164]\ttrain-mlogloss:0.15171\teval-mlogloss:0.23326\n",
      "[165]\ttrain-mlogloss:0.15122\teval-mlogloss:0.23307\n",
      "[166]\ttrain-mlogloss:0.15071\teval-mlogloss:0.23336\n",
      "[167]\ttrain-mlogloss:0.15028\teval-mlogloss:0.23310\n",
      "[168]\ttrain-mlogloss:0.14973\teval-mlogloss:0.23326\n",
      "[169]\ttrain-mlogloss:0.14918\teval-mlogloss:0.23349\n",
      "[170]\ttrain-mlogloss:0.14866\teval-mlogloss:0.23339\n",
      "[171]\ttrain-mlogloss:0.14818\teval-mlogloss:0.23347\n",
      "[172]\ttrain-mlogloss:0.14767\teval-mlogloss:0.23326\n",
      "[173]\ttrain-mlogloss:0.14716\teval-mlogloss:0.23354\n",
      "[174]\ttrain-mlogloss:0.14672\teval-mlogloss:0.23399\n",
      "[175]\ttrain-mlogloss:0.14615\teval-mlogloss:0.23425\n",
      "[176]\ttrain-mlogloss:0.14562\teval-mlogloss:0.23424\n",
      "[177]\ttrain-mlogloss:0.14501\teval-mlogloss:0.23435\n",
      "[178]\ttrain-mlogloss:0.14453\teval-mlogloss:0.23414\n",
      "[179]\ttrain-mlogloss:0.14395\teval-mlogloss:0.23432\n",
      "[180]\ttrain-mlogloss:0.14352\teval-mlogloss:0.23467\n",
      "[181]\ttrain-mlogloss:0.14307\teval-mlogloss:0.23476\n",
      "[182]\ttrain-mlogloss:0.14252\teval-mlogloss:0.23480\n",
      "[183]\ttrain-mlogloss:0.14195\teval-mlogloss:0.23496\n",
      "[184]\ttrain-mlogloss:0.14155\teval-mlogloss:0.23507\n",
      "[185]\ttrain-mlogloss:0.14103\teval-mlogloss:0.23487\n",
      "[186]\ttrain-mlogloss:0.14057\teval-mlogloss:0.23504\n",
      "[187]\ttrain-mlogloss:0.14011\teval-mlogloss:0.23520\n",
      "[188]\ttrain-mlogloss:0.13967\teval-mlogloss:0.23560\n",
      "[189]\ttrain-mlogloss:0.13927\teval-mlogloss:0.23552\n",
      "[190]\ttrain-mlogloss:0.13883\teval-mlogloss:0.23562\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[191]\ttrain-mlogloss:0.13843\teval-mlogloss:0.23577\n",
      "[192]\ttrain-mlogloss:0.13792\teval-mlogloss:0.23590\n",
      "[193]\ttrain-mlogloss:0.13741\teval-mlogloss:0.23592\n",
      "[194]\ttrain-mlogloss:0.13706\teval-mlogloss:0.23627\n",
      "[195]\ttrain-mlogloss:0.13651\teval-mlogloss:0.23637\n",
      "[196]\ttrain-mlogloss:0.13614\teval-mlogloss:0.23644\n",
      "[197]\ttrain-mlogloss:0.13570\teval-mlogloss:0.23646\n",
      "[198]\ttrain-mlogloss:0.13516\teval-mlogloss:0.23672\n",
      "[199]\ttrain-mlogloss:0.13477\teval-mlogloss:0.23669\n",
      "[200]\ttrain-mlogloss:0.13440\teval-mlogloss:0.23687\n",
      "[201]\ttrain-mlogloss:0.13393\teval-mlogloss:0.23696\n",
      "[202]\ttrain-mlogloss:0.13359\teval-mlogloss:0.23698\n",
      "[203]\ttrain-mlogloss:0.13309\teval-mlogloss:0.23702\n",
      "[204]\ttrain-mlogloss:0.13280\teval-mlogloss:0.23710\n",
      "[205]\ttrain-mlogloss:0.13242\teval-mlogloss:0.23722\n",
      "[206]\ttrain-mlogloss:0.13206\teval-mlogloss:0.23731\n",
      "[207]\ttrain-mlogloss:0.13164\teval-mlogloss:0.23742\n",
      "[208]\ttrain-mlogloss:0.13136\teval-mlogloss:0.23752\n",
      "[209]\ttrain-mlogloss:0.13100\teval-mlogloss:0.23766\n",
      "[210]\ttrain-mlogloss:0.13057\teval-mlogloss:0.23770\n",
      "[211]\ttrain-mlogloss:0.13021\teval-mlogloss:0.23797\n",
      "[212]\ttrain-mlogloss:0.12979\teval-mlogloss:0.23808\n",
      "[213]\ttrain-mlogloss:0.12935\teval-mlogloss:0.23815\n",
      "[214]\ttrain-mlogloss:0.12897\teval-mlogloss:0.23828\n",
      "Stopping. Best iteration:\n",
      "[114]\ttrain-mlogloss:0.18642\teval-mlogloss:0.22957\n",
      "\n",
      "xgb now score is: [2.2977992902230473, 2.4689512671623377]\n",
      "[0]\ttrain-mlogloss:0.67097\teval-mlogloss:0.67102\n",
      "Multiple eval metrics have been passed: 'eval-mlogloss' will be used for early stopping.\n",
      "\n",
      "Will train until eval-mlogloss hasn't improved in 100 rounds.\n",
      "[1]\ttrain-mlogloss:0.65041\teval-mlogloss:0.65031\n",
      "[2]\ttrain-mlogloss:0.63094\teval-mlogloss:0.63062\n",
      "[3]\ttrain-mlogloss:0.61251\teval-mlogloss:0.61183\n",
      "[4]\ttrain-mlogloss:0.59506\teval-mlogloss:0.59410\n",
      "[5]\ttrain-mlogloss:0.57873\teval-mlogloss:0.57748\n",
      "[6]\ttrain-mlogloss:0.56294\teval-mlogloss:0.56144\n",
      "[7]\ttrain-mlogloss:0.54803\teval-mlogloss:0.54663\n",
      "[8]\ttrain-mlogloss:0.53409\teval-mlogloss:0.53243\n",
      "[9]\ttrain-mlogloss:0.52082\teval-mlogloss:0.51891\n",
      "[10]\ttrain-mlogloss:0.50816\teval-mlogloss:0.50575\n",
      "[11]\ttrain-mlogloss:0.49599\teval-mlogloss:0.49346\n",
      "[12]\ttrain-mlogloss:0.48435\teval-mlogloss:0.48159\n",
      "[13]\ttrain-mlogloss:0.47321\teval-mlogloss:0.47042\n",
      "[14]\ttrain-mlogloss:0.46263\teval-mlogloss:0.45979\n",
      "[15]\ttrain-mlogloss:0.45261\teval-mlogloss:0.44995\n",
      "[16]\ttrain-mlogloss:0.44299\teval-mlogloss:0.44025\n",
      "[17]\ttrain-mlogloss:0.43383\teval-mlogloss:0.43107\n",
      "[18]\ttrain-mlogloss:0.42513\teval-mlogloss:0.42235\n",
      "[19]\ttrain-mlogloss:0.41669\teval-mlogloss:0.41378\n",
      "[20]\ttrain-mlogloss:0.40868\teval-mlogloss:0.40581\n",
      "[21]\ttrain-mlogloss:0.40102\teval-mlogloss:0.39819\n",
      "[22]\ttrain-mlogloss:0.39357\teval-mlogloss:0.39059\n",
      "[23]\ttrain-mlogloss:0.38635\teval-mlogloss:0.38335\n",
      "[24]\ttrain-mlogloss:0.37956\teval-mlogloss:0.37652\n",
      "[25]\ttrain-mlogloss:0.37304\teval-mlogloss:0.37010\n",
      "[26]\ttrain-mlogloss:0.36687\teval-mlogloss:0.36390\n",
      "[27]\ttrain-mlogloss:0.36086\teval-mlogloss:0.35796\n",
      "[28]\ttrain-mlogloss:0.35516\teval-mlogloss:0.35231\n",
      "[29]\ttrain-mlogloss:0.34964\teval-mlogloss:0.34677\n",
      "[30]\ttrain-mlogloss:0.34441\teval-mlogloss:0.34149\n",
      "[31]\ttrain-mlogloss:0.33937\teval-mlogloss:0.33646\n",
      "[32]\ttrain-mlogloss:0.33459\teval-mlogloss:0.33197\n",
      "[33]\ttrain-mlogloss:0.32995\teval-mlogloss:0.32748\n",
      "[34]\ttrain-mlogloss:0.32549\teval-mlogloss:0.32302\n",
      "[35]\ttrain-mlogloss:0.32122\teval-mlogloss:0.31854\n",
      "[36]\ttrain-mlogloss:0.31692\teval-mlogloss:0.31461\n",
      "[37]\ttrain-mlogloss:0.31288\teval-mlogloss:0.31076\n",
      "[38]\ttrain-mlogloss:0.30909\teval-mlogloss:0.30717\n",
      "[39]\ttrain-mlogloss:0.30545\teval-mlogloss:0.30336\n",
      "[40]\ttrain-mlogloss:0.30185\teval-mlogloss:0.29986\n",
      "[41]\ttrain-mlogloss:0.29837\teval-mlogloss:0.29667\n",
      "[42]\ttrain-mlogloss:0.29514\teval-mlogloss:0.29355\n",
      "[43]\ttrain-mlogloss:0.29169\teval-mlogloss:0.29052\n",
      "[44]\ttrain-mlogloss:0.28835\teval-mlogloss:0.28760\n",
      "[45]\ttrain-mlogloss:0.28529\teval-mlogloss:0.28478\n",
      "[46]\ttrain-mlogloss:0.28223\teval-mlogloss:0.28215\n",
      "[47]\ttrain-mlogloss:0.27966\teval-mlogloss:0.27955\n",
      "[48]\ttrain-mlogloss:0.27702\teval-mlogloss:0.27728\n",
      "[49]\ttrain-mlogloss:0.27431\teval-mlogloss:0.27484\n",
      "[50]\ttrain-mlogloss:0.27178\teval-mlogloss:0.27252\n",
      "[51]\ttrain-mlogloss:0.26930\teval-mlogloss:0.27047\n",
      "[52]\ttrain-mlogloss:0.26683\teval-mlogloss:0.26843\n",
      "[53]\ttrain-mlogloss:0.26421\teval-mlogloss:0.26637\n",
      "[54]\ttrain-mlogloss:0.26172\teval-mlogloss:0.26474\n",
      "[55]\ttrain-mlogloss:0.25941\teval-mlogloss:0.26292\n",
      "[56]\ttrain-mlogloss:0.25711\teval-mlogloss:0.26158\n",
      "[57]\ttrain-mlogloss:0.25497\teval-mlogloss:0.25991\n",
      "[58]\ttrain-mlogloss:0.25309\teval-mlogloss:0.25843\n",
      "[59]\ttrain-mlogloss:0.25119\teval-mlogloss:0.25706\n",
      "[60]\ttrain-mlogloss:0.24918\teval-mlogloss:0.25563\n",
      "[61]\ttrain-mlogloss:0.24741\teval-mlogloss:0.25435\n",
      "[62]\ttrain-mlogloss:0.24564\teval-mlogloss:0.25320\n",
      "[63]\ttrain-mlogloss:0.24389\teval-mlogloss:0.25222\n",
      "[64]\ttrain-mlogloss:0.24206\teval-mlogloss:0.25103\n",
      "[65]\ttrain-mlogloss:0.24044\teval-mlogloss:0.25021\n",
      "[66]\ttrain-mlogloss:0.23879\teval-mlogloss:0.24930\n",
      "[67]\ttrain-mlogloss:0.23725\teval-mlogloss:0.24832\n",
      "[68]\ttrain-mlogloss:0.23587\teval-mlogloss:0.24733\n",
      "[69]\ttrain-mlogloss:0.23398\teval-mlogloss:0.24624\n",
      "[70]\ttrain-mlogloss:0.23230\teval-mlogloss:0.24545\n",
      "[71]\ttrain-mlogloss:0.23081\teval-mlogloss:0.24458\n",
      "[72]\ttrain-mlogloss:0.22910\teval-mlogloss:0.24402\n",
      "[73]\ttrain-mlogloss:0.22752\teval-mlogloss:0.24327\n",
      "[74]\ttrain-mlogloss:0.22595\teval-mlogloss:0.24253\n",
      "[75]\ttrain-mlogloss:0.22461\teval-mlogloss:0.24199\n",
      "[76]\ttrain-mlogloss:0.22339\teval-mlogloss:0.24146\n",
      "[77]\ttrain-mlogloss:0.22200\teval-mlogloss:0.24078\n",
      "[78]\ttrain-mlogloss:0.22077\teval-mlogloss:0.24006\n",
      "[79]\ttrain-mlogloss:0.21938\teval-mlogloss:0.23953\n",
      "[80]\ttrain-mlogloss:0.21805\teval-mlogloss:0.23900\n",
      "[81]\ttrain-mlogloss:0.21698\teval-mlogloss:0.23864\n",
      "[82]\ttrain-mlogloss:0.21573\teval-mlogloss:0.23830\n",
      "[83]\ttrain-mlogloss:0.21443\teval-mlogloss:0.23783\n",
      "[84]\ttrain-mlogloss:0.21330\teval-mlogloss:0.23733\n",
      "[85]\ttrain-mlogloss:0.21195\teval-mlogloss:0.23684\n",
      "[86]\ttrain-mlogloss:0.21070\teval-mlogloss:0.23656\n",
      "[87]\ttrain-mlogloss:0.20968\teval-mlogloss:0.23624\n",
      "[88]\ttrain-mlogloss:0.20875\teval-mlogloss:0.23581\n",
      "[89]\ttrain-mlogloss:0.20756\teval-mlogloss:0.23553\n",
      "[90]\ttrain-mlogloss:0.20636\teval-mlogloss:0.23537\n",
      "[91]\ttrain-mlogloss:0.20531\teval-mlogloss:0.23523\n",
      "[92]\ttrain-mlogloss:0.20415\teval-mlogloss:0.23505\n",
      "[93]\ttrain-mlogloss:0.20301\teval-mlogloss:0.23486\n",
      "[94]\ttrain-mlogloss:0.20195\teval-mlogloss:0.23440\n",
      "[95]\ttrain-mlogloss:0.20069\teval-mlogloss:0.23439\n",
      "[96]\ttrain-mlogloss:0.19981\teval-mlogloss:0.23430\n",
      "[97]\ttrain-mlogloss:0.19908\teval-mlogloss:0.23391\n",
      "[98]\ttrain-mlogloss:0.19796\teval-mlogloss:0.23404\n",
      "[99]\ttrain-mlogloss:0.19703\teval-mlogloss:0.23381\n",
      "[100]\ttrain-mlogloss:0.19598\teval-mlogloss:0.23390\n",
      "[101]\ttrain-mlogloss:0.19489\teval-mlogloss:0.23362\n",
      "[102]\ttrain-mlogloss:0.19420\teval-mlogloss:0.23353\n",
      "[103]\ttrain-mlogloss:0.19324\teval-mlogloss:0.23351\n",
      "[104]\ttrain-mlogloss:0.19219\teval-mlogloss:0.23352\n",
      "[105]\ttrain-mlogloss:0.19127\teval-mlogloss:0.23353\n",
      "[106]\ttrain-mlogloss:0.19043\teval-mlogloss:0.23340\n",
      "[107]\ttrain-mlogloss:0.18952\teval-mlogloss:0.23336\n",
      "[108]\ttrain-mlogloss:0.18863\teval-mlogloss:0.23329\n",
      "[109]\ttrain-mlogloss:0.18766\teval-mlogloss:0.23337\n",
      "[110]\ttrain-mlogloss:0.18682\teval-mlogloss:0.23340\n",
      "[111]\ttrain-mlogloss:0.18598\teval-mlogloss:0.23361\n",
      "[112]\ttrain-mlogloss:0.18517\teval-mlogloss:0.23352\n",
      "[113]\ttrain-mlogloss:0.18447\teval-mlogloss:0.23354\n",
      "[114]\ttrain-mlogloss:0.18369\teval-mlogloss:0.23365\n",
      "[115]\ttrain-mlogloss:0.18289\teval-mlogloss:0.23368\n",
      "[116]\ttrain-mlogloss:0.18200\teval-mlogloss:0.23355\n",
      "[117]\ttrain-mlogloss:0.18114\teval-mlogloss:0.23347\n",
      "[118]\ttrain-mlogloss:0.18037\teval-mlogloss:0.23335\n",
      "[119]\ttrain-mlogloss:0.17954\teval-mlogloss:0.23356\n",
      "[120]\ttrain-mlogloss:0.17870\teval-mlogloss:0.23370\n",
      "[121]\ttrain-mlogloss:0.17790\teval-mlogloss:0.23373\n",
      "[122]\ttrain-mlogloss:0.17713\teval-mlogloss:0.23395\n",
      "[123]\ttrain-mlogloss:0.17630\teval-mlogloss:0.23405\n",
      "[124]\ttrain-mlogloss:0.17565\teval-mlogloss:0.23412\n",
      "[125]\ttrain-mlogloss:0.17480\teval-mlogloss:0.23434\n",
      "[126]\ttrain-mlogloss:0.17410\teval-mlogloss:0.23441\n",
      "[127]\ttrain-mlogloss:0.17348\teval-mlogloss:0.23461\n",
      "[128]\ttrain-mlogloss:0.17276\teval-mlogloss:0.23490\n",
      "[129]\ttrain-mlogloss:0.17191\teval-mlogloss:0.23513\n",
      "[130]\ttrain-mlogloss:0.17104\teval-mlogloss:0.23513\n",
      "[131]\ttrain-mlogloss:0.17048\teval-mlogloss:0.23549\n",
      "[132]\ttrain-mlogloss:0.16969\teval-mlogloss:0.23563\n",
      "[133]\ttrain-mlogloss:0.16900\teval-mlogloss:0.23560\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[134]\ttrain-mlogloss:0.16837\teval-mlogloss:0.23582\n",
      "[135]\ttrain-mlogloss:0.16761\teval-mlogloss:0.23593\n",
      "[136]\ttrain-mlogloss:0.16688\teval-mlogloss:0.23587\n",
      "[137]\ttrain-mlogloss:0.16620\teval-mlogloss:0.23582\n",
      "[138]\ttrain-mlogloss:0.16544\teval-mlogloss:0.23623\n",
      "[139]\ttrain-mlogloss:0.16475\teval-mlogloss:0.23646\n",
      "[140]\ttrain-mlogloss:0.16393\teval-mlogloss:0.23681\n",
      "[141]\ttrain-mlogloss:0.16343\teval-mlogloss:0.23696\n",
      "[142]\ttrain-mlogloss:0.16283\teval-mlogloss:0.23732\n",
      "[143]\ttrain-mlogloss:0.16214\teval-mlogloss:0.23740\n",
      "[144]\ttrain-mlogloss:0.16159\teval-mlogloss:0.23749\n",
      "[145]\ttrain-mlogloss:0.16088\teval-mlogloss:0.23761\n",
      "[146]\ttrain-mlogloss:0.16036\teval-mlogloss:0.23780\n",
      "[147]\ttrain-mlogloss:0.15976\teval-mlogloss:0.23807\n",
      "[148]\ttrain-mlogloss:0.15916\teval-mlogloss:0.23809\n",
      "[149]\ttrain-mlogloss:0.15851\teval-mlogloss:0.23841\n",
      "[150]\ttrain-mlogloss:0.15791\teval-mlogloss:0.23857\n",
      "[151]\ttrain-mlogloss:0.15728\teval-mlogloss:0.23885\n",
      "[152]\ttrain-mlogloss:0.15659\teval-mlogloss:0.23915\n",
      "[153]\ttrain-mlogloss:0.15604\teval-mlogloss:0.23914\n",
      "[154]\ttrain-mlogloss:0.15546\teval-mlogloss:0.23930\n",
      "[155]\ttrain-mlogloss:0.15480\teval-mlogloss:0.23940\n",
      "[156]\ttrain-mlogloss:0.15415\teval-mlogloss:0.23947\n",
      "[157]\ttrain-mlogloss:0.15353\teval-mlogloss:0.23974\n",
      "[158]\ttrain-mlogloss:0.15290\teval-mlogloss:0.23979\n",
      "[159]\ttrain-mlogloss:0.15229\teval-mlogloss:0.23988\n",
      "[160]\ttrain-mlogloss:0.15168\teval-mlogloss:0.24019\n",
      "[161]\ttrain-mlogloss:0.15123\teval-mlogloss:0.24028\n",
      "[162]\ttrain-mlogloss:0.15083\teval-mlogloss:0.24036\n",
      "[163]\ttrain-mlogloss:0.15035\teval-mlogloss:0.24067\n",
      "[164]\ttrain-mlogloss:0.14991\teval-mlogloss:0.24098\n",
      "[165]\ttrain-mlogloss:0.14938\teval-mlogloss:0.24102\n",
      "[166]\ttrain-mlogloss:0.14885\teval-mlogloss:0.24115\n",
      "[167]\ttrain-mlogloss:0.14830\teval-mlogloss:0.24146\n",
      "[168]\ttrain-mlogloss:0.14771\teval-mlogloss:0.24180\n",
      "[169]\ttrain-mlogloss:0.14715\teval-mlogloss:0.24198\n",
      "[170]\ttrain-mlogloss:0.14655\teval-mlogloss:0.24211\n",
      "[171]\ttrain-mlogloss:0.14604\teval-mlogloss:0.24229\n",
      "[172]\ttrain-mlogloss:0.14562\teval-mlogloss:0.24244\n",
      "[173]\ttrain-mlogloss:0.14508\teval-mlogloss:0.24265\n",
      "[174]\ttrain-mlogloss:0.14450\teval-mlogloss:0.24262\n",
      "[175]\ttrain-mlogloss:0.14400\teval-mlogloss:0.24288\n",
      "[176]\ttrain-mlogloss:0.14350\teval-mlogloss:0.24283\n",
      "[177]\ttrain-mlogloss:0.14310\teval-mlogloss:0.24326\n",
      "[178]\ttrain-mlogloss:0.14255\teval-mlogloss:0.24321\n",
      "[179]\ttrain-mlogloss:0.14206\teval-mlogloss:0.24311\n",
      "[180]\ttrain-mlogloss:0.14157\teval-mlogloss:0.24334\n",
      "[181]\ttrain-mlogloss:0.14122\teval-mlogloss:0.24367\n",
      "[182]\ttrain-mlogloss:0.14080\teval-mlogloss:0.24372\n",
      "[183]\ttrain-mlogloss:0.14027\teval-mlogloss:0.24402\n",
      "[184]\ttrain-mlogloss:0.13983\teval-mlogloss:0.24423\n",
      "[185]\ttrain-mlogloss:0.13936\teval-mlogloss:0.24417\n",
      "[186]\ttrain-mlogloss:0.13894\teval-mlogloss:0.24442\n",
      "[187]\ttrain-mlogloss:0.13857\teval-mlogloss:0.24466\n",
      "[188]\ttrain-mlogloss:0.13823\teval-mlogloss:0.24476\n",
      "[189]\ttrain-mlogloss:0.13785\teval-mlogloss:0.24513\n",
      "[190]\ttrain-mlogloss:0.13748\teval-mlogloss:0.24543\n",
      "[191]\ttrain-mlogloss:0.13707\teval-mlogloss:0.24560\n",
      "[192]\ttrain-mlogloss:0.13650\teval-mlogloss:0.24580\n",
      "[193]\ttrain-mlogloss:0.13616\teval-mlogloss:0.24609\n",
      "[194]\ttrain-mlogloss:0.13578\teval-mlogloss:0.24637\n",
      "[195]\ttrain-mlogloss:0.13548\teval-mlogloss:0.24657\n",
      "[196]\ttrain-mlogloss:0.13513\teval-mlogloss:0.24669\n",
      "[197]\ttrain-mlogloss:0.13474\teval-mlogloss:0.24708\n",
      "[198]\ttrain-mlogloss:0.13436\teval-mlogloss:0.24733\n",
      "[199]\ttrain-mlogloss:0.13399\teval-mlogloss:0.24764\n",
      "[200]\ttrain-mlogloss:0.13355\teval-mlogloss:0.24765\n",
      "[201]\ttrain-mlogloss:0.13311\teval-mlogloss:0.24797\n",
      "[202]\ttrain-mlogloss:0.13271\teval-mlogloss:0.24797\n",
      "[203]\ttrain-mlogloss:0.13231\teval-mlogloss:0.24798\n",
      "[204]\ttrain-mlogloss:0.13200\teval-mlogloss:0.24828\n",
      "[205]\ttrain-mlogloss:0.13163\teval-mlogloss:0.24845\n",
      "[206]\ttrain-mlogloss:0.13128\teval-mlogloss:0.24863\n",
      "[207]\ttrain-mlogloss:0.13099\teval-mlogloss:0.24868\n",
      "[208]\ttrain-mlogloss:0.13067\teval-mlogloss:0.24882\n",
      "Stopping. Best iteration:\n",
      "[108]\ttrain-mlogloss:0.18863\teval-mlogloss:0.23329\n",
      "\n",
      "xgb now score is: [2.2977992902230473, 2.4689512671623377, 2.4576862342189996]\n",
      "[0]\ttrain-mlogloss:0.67057\teval-mlogloss:0.67202\n",
      "Multiple eval metrics have been passed: 'eval-mlogloss' will be used for early stopping.\n",
      "\n",
      "Will train until eval-mlogloss hasn't improved in 100 rounds.\n",
      "[1]\ttrain-mlogloss:0.64939\teval-mlogloss:0.65239\n",
      "[2]\ttrain-mlogloss:0.62938\teval-mlogloss:0.63351\n",
      "[3]\ttrain-mlogloss:0.61053\teval-mlogloss:0.61586\n",
      "[4]\ttrain-mlogloss:0.59271\teval-mlogloss:0.59933\n",
      "[5]\ttrain-mlogloss:0.57609\teval-mlogloss:0.58386\n",
      "[6]\ttrain-mlogloss:0.56006\teval-mlogloss:0.56907\n",
      "[7]\ttrain-mlogloss:0.54473\teval-mlogloss:0.55500\n",
      "[8]\ttrain-mlogloss:0.53012\teval-mlogloss:0.54141\n",
      "[9]\ttrain-mlogloss:0.51638\teval-mlogloss:0.52858\n",
      "[10]\ttrain-mlogloss:0.50339\teval-mlogloss:0.51682\n",
      "[11]\ttrain-mlogloss:0.49086\teval-mlogloss:0.50523\n",
      "[12]\ttrain-mlogloss:0.47881\teval-mlogloss:0.49424\n",
      "[13]\ttrain-mlogloss:0.46726\teval-mlogloss:0.48388\n",
      "[14]\ttrain-mlogloss:0.45648\teval-mlogloss:0.47399\n",
      "[15]\ttrain-mlogloss:0.44616\teval-mlogloss:0.46479\n",
      "[16]\ttrain-mlogloss:0.43633\teval-mlogloss:0.45607\n",
      "[17]\ttrain-mlogloss:0.42681\teval-mlogloss:0.44755\n",
      "[18]\ttrain-mlogloss:0.41770\teval-mlogloss:0.43947\n",
      "[19]\ttrain-mlogloss:0.40904\teval-mlogloss:0.43179\n",
      "[20]\ttrain-mlogloss:0.40078\teval-mlogloss:0.42450\n",
      "[21]\ttrain-mlogloss:0.39289\teval-mlogloss:0.41750\n",
      "[22]\ttrain-mlogloss:0.38540\teval-mlogloss:0.41082\n",
      "[23]\ttrain-mlogloss:0.37830\teval-mlogloss:0.40470\n",
      "[24]\ttrain-mlogloss:0.37139\teval-mlogloss:0.39859\n",
      "[25]\ttrain-mlogloss:0.36475\teval-mlogloss:0.39297\n",
      "[26]\ttrain-mlogloss:0.35837\teval-mlogloss:0.38739\n",
      "[27]\ttrain-mlogloss:0.35231\teval-mlogloss:0.38212\n",
      "[28]\ttrain-mlogloss:0.34639\teval-mlogloss:0.37715\n",
      "[29]\ttrain-mlogloss:0.34073\teval-mlogloss:0.37239\n",
      "[30]\ttrain-mlogloss:0.33546\teval-mlogloss:0.36802\n",
      "[31]\ttrain-mlogloss:0.33044\teval-mlogloss:0.36370\n",
      "[32]\ttrain-mlogloss:0.32549\teval-mlogloss:0.35970\n",
      "[33]\ttrain-mlogloss:0.32055\teval-mlogloss:0.35570\n",
      "[34]\ttrain-mlogloss:0.31592\teval-mlogloss:0.35189\n",
      "[35]\ttrain-mlogloss:0.31137\teval-mlogloss:0.34825\n",
      "[36]\ttrain-mlogloss:0.30713\teval-mlogloss:0.34493\n",
      "[37]\ttrain-mlogloss:0.30297\teval-mlogloss:0.34168\n",
      "[38]\ttrain-mlogloss:0.29890\teval-mlogloss:0.33861\n",
      "[39]\ttrain-mlogloss:0.29516\teval-mlogloss:0.33566\n",
      "[40]\ttrain-mlogloss:0.29152\teval-mlogloss:0.33296\n",
      "[41]\ttrain-mlogloss:0.28784\teval-mlogloss:0.33032\n",
      "[42]\ttrain-mlogloss:0.28450\teval-mlogloss:0.32760\n",
      "[43]\ttrain-mlogloss:0.28131\teval-mlogloss:0.32544\n",
      "[44]\ttrain-mlogloss:0.27798\teval-mlogloss:0.32327\n",
      "[45]\ttrain-mlogloss:0.27501\teval-mlogloss:0.32102\n",
      "[46]\ttrain-mlogloss:0.27204\teval-mlogloss:0.31900\n",
      "[47]\ttrain-mlogloss:0.26920\teval-mlogloss:0.31689\n",
      "[48]\ttrain-mlogloss:0.26652\teval-mlogloss:0.31492\n",
      "[49]\ttrain-mlogloss:0.26393\teval-mlogloss:0.31312\n",
      "[50]\ttrain-mlogloss:0.26132\teval-mlogloss:0.31148\n",
      "[51]\ttrain-mlogloss:0.25885\teval-mlogloss:0.30999\n",
      "[52]\ttrain-mlogloss:0.25654\teval-mlogloss:0.30849\n",
      "[53]\ttrain-mlogloss:0.25435\teval-mlogloss:0.30696\n",
      "[54]\ttrain-mlogloss:0.25199\teval-mlogloss:0.30576\n",
      "[55]\ttrain-mlogloss:0.24984\teval-mlogloss:0.30437\n",
      "[56]\ttrain-mlogloss:0.24755\teval-mlogloss:0.30317\n",
      "[57]\ttrain-mlogloss:0.24543\teval-mlogloss:0.30206\n",
      "[58]\ttrain-mlogloss:0.24340\teval-mlogloss:0.30082\n",
      "[59]\ttrain-mlogloss:0.24137\teval-mlogloss:0.29992\n",
      "[60]\ttrain-mlogloss:0.23931\teval-mlogloss:0.29890\n",
      "[61]\ttrain-mlogloss:0.23747\teval-mlogloss:0.29793\n",
      "[62]\ttrain-mlogloss:0.23577\teval-mlogloss:0.29701\n",
      "[63]\ttrain-mlogloss:0.23391\teval-mlogloss:0.29649\n",
      "[64]\ttrain-mlogloss:0.23188\teval-mlogloss:0.29605\n",
      "[65]\ttrain-mlogloss:0.23036\teval-mlogloss:0.29527\n",
      "[66]\ttrain-mlogloss:0.22847\teval-mlogloss:0.29470\n",
      "[67]\ttrain-mlogloss:0.22703\teval-mlogloss:0.29413\n",
      "[68]\ttrain-mlogloss:0.22580\teval-mlogloss:0.29344\n",
      "[69]\ttrain-mlogloss:0.22424\teval-mlogloss:0.29284\n",
      "[70]\ttrain-mlogloss:0.22281\teval-mlogloss:0.29226\n",
      "[71]\ttrain-mlogloss:0.22140\teval-mlogloss:0.29164\n",
      "[72]\ttrain-mlogloss:0.21974\teval-mlogloss:0.29112\n",
      "[73]\ttrain-mlogloss:0.21824\teval-mlogloss:0.29073\n",
      "[74]\ttrain-mlogloss:0.21697\teval-mlogloss:0.29051\n",
      "[75]\ttrain-mlogloss:0.21578\teval-mlogloss:0.29003\n",
      "[76]\ttrain-mlogloss:0.21460\teval-mlogloss:0.28977\n",
      "[77]\ttrain-mlogloss:0.21337\teval-mlogloss:0.28948\n",
      "[78]\ttrain-mlogloss:0.21198\teval-mlogloss:0.28921\n",
      "[79]\ttrain-mlogloss:0.21059\teval-mlogloss:0.28893\n",
      "[80]\ttrain-mlogloss:0.20942\teval-mlogloss:0.28869\n",
      "[81]\ttrain-mlogloss:0.20841\teval-mlogloss:0.28829\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[82]\ttrain-mlogloss:0.20722\teval-mlogloss:0.28800\n",
      "[83]\ttrain-mlogloss:0.20591\teval-mlogloss:0.28770\n",
      "[84]\ttrain-mlogloss:0.20500\teval-mlogloss:0.28725\n",
      "[85]\ttrain-mlogloss:0.20390\teval-mlogloss:0.28720\n",
      "[86]\ttrain-mlogloss:0.20270\teval-mlogloss:0.28711\n",
      "[87]\ttrain-mlogloss:0.20162\teval-mlogloss:0.28697\n",
      "[88]\ttrain-mlogloss:0.20053\teval-mlogloss:0.28681\n",
      "[89]\ttrain-mlogloss:0.19962\teval-mlogloss:0.28680\n",
      "[90]\ttrain-mlogloss:0.19838\teval-mlogloss:0.28673\n",
      "[91]\ttrain-mlogloss:0.19747\teval-mlogloss:0.28675\n",
      "[92]\ttrain-mlogloss:0.19663\teval-mlogloss:0.28709\n",
      "[93]\ttrain-mlogloss:0.19569\teval-mlogloss:0.28694\n",
      "[94]\ttrain-mlogloss:0.19501\teval-mlogloss:0.28719\n",
      "[95]\ttrain-mlogloss:0.19433\teval-mlogloss:0.28731\n",
      "[96]\ttrain-mlogloss:0.19347\teval-mlogloss:0.28741\n",
      "[97]\ttrain-mlogloss:0.19256\teval-mlogloss:0.28715\n",
      "[98]\ttrain-mlogloss:0.19167\teval-mlogloss:0.28697\n",
      "[99]\ttrain-mlogloss:0.19065\teval-mlogloss:0.28705\n",
      "[100]\ttrain-mlogloss:0.18955\teval-mlogloss:0.28721\n",
      "[101]\ttrain-mlogloss:0.18846\teval-mlogloss:0.28694\n",
      "[102]\ttrain-mlogloss:0.18745\teval-mlogloss:0.28674\n",
      "[103]\ttrain-mlogloss:0.18658\teval-mlogloss:0.28686\n",
      "[104]\ttrain-mlogloss:0.18572\teval-mlogloss:0.28675\n",
      "[105]\ttrain-mlogloss:0.18492\teval-mlogloss:0.28650\n",
      "[106]\ttrain-mlogloss:0.18411\teval-mlogloss:0.28640\n",
      "[107]\ttrain-mlogloss:0.18318\teval-mlogloss:0.28663\n",
      "[108]\ttrain-mlogloss:0.18234\teval-mlogloss:0.28664\n",
      "[109]\ttrain-mlogloss:0.18161\teval-mlogloss:0.28645\n",
      "[110]\ttrain-mlogloss:0.18088\teval-mlogloss:0.28643\n",
      "[111]\ttrain-mlogloss:0.18008\teval-mlogloss:0.28651\n",
      "[112]\ttrain-mlogloss:0.17926\teval-mlogloss:0.28657\n",
      "[113]\ttrain-mlogloss:0.17844\teval-mlogloss:0.28672\n",
      "[114]\ttrain-mlogloss:0.17761\teval-mlogloss:0.28661\n",
      "[115]\ttrain-mlogloss:0.17688\teval-mlogloss:0.28648\n",
      "[116]\ttrain-mlogloss:0.17614\teval-mlogloss:0.28655\n",
      "[117]\ttrain-mlogloss:0.17535\teval-mlogloss:0.28661\n",
      "[118]\ttrain-mlogloss:0.17462\teval-mlogloss:0.28674\n",
      "[119]\ttrain-mlogloss:0.17383\teval-mlogloss:0.28670\n",
      "[120]\ttrain-mlogloss:0.17329\teval-mlogloss:0.28679\n",
      "[121]\ttrain-mlogloss:0.17255\teval-mlogloss:0.28725\n",
      "[122]\ttrain-mlogloss:0.17178\teval-mlogloss:0.28753\n",
      "[123]\ttrain-mlogloss:0.17107\teval-mlogloss:0.28797\n",
      "[124]\ttrain-mlogloss:0.17028\teval-mlogloss:0.28835\n",
      "[125]\ttrain-mlogloss:0.16959\teval-mlogloss:0.28863\n",
      "[126]\ttrain-mlogloss:0.16897\teval-mlogloss:0.28862\n",
      "[127]\ttrain-mlogloss:0.16826\teval-mlogloss:0.28874\n",
      "[128]\ttrain-mlogloss:0.16749\teval-mlogloss:0.28889\n",
      "[129]\ttrain-mlogloss:0.16687\teval-mlogloss:0.28897\n",
      "[130]\ttrain-mlogloss:0.16615\teval-mlogloss:0.28901\n",
      "[131]\ttrain-mlogloss:0.16551\teval-mlogloss:0.28924\n",
      "[132]\ttrain-mlogloss:0.16493\teval-mlogloss:0.28945\n",
      "[133]\ttrain-mlogloss:0.16438\teval-mlogloss:0.28956\n",
      "[134]\ttrain-mlogloss:0.16362\teval-mlogloss:0.28956\n",
      "[135]\ttrain-mlogloss:0.16294\teval-mlogloss:0.28989\n",
      "[136]\ttrain-mlogloss:0.16233\teval-mlogloss:0.29027\n",
      "[137]\ttrain-mlogloss:0.16173\teval-mlogloss:0.29057\n",
      "[138]\ttrain-mlogloss:0.16115\teval-mlogloss:0.29080\n",
      "[139]\ttrain-mlogloss:0.16053\teval-mlogloss:0.29102\n",
      "[140]\ttrain-mlogloss:0.15984\teval-mlogloss:0.29141\n",
      "[141]\ttrain-mlogloss:0.15908\teval-mlogloss:0.29162\n",
      "[142]\ttrain-mlogloss:0.15852\teval-mlogloss:0.29150\n",
      "[143]\ttrain-mlogloss:0.15798\teval-mlogloss:0.29151\n",
      "[144]\ttrain-mlogloss:0.15741\teval-mlogloss:0.29178\n",
      "[145]\ttrain-mlogloss:0.15684\teval-mlogloss:0.29199\n",
      "[146]\ttrain-mlogloss:0.15631\teval-mlogloss:0.29238\n",
      "[147]\ttrain-mlogloss:0.15565\teval-mlogloss:0.29260\n",
      "[148]\ttrain-mlogloss:0.15498\teval-mlogloss:0.29291\n",
      "[149]\ttrain-mlogloss:0.15456\teval-mlogloss:0.29296\n",
      "[150]\ttrain-mlogloss:0.15404\teval-mlogloss:0.29306\n",
      "[151]\ttrain-mlogloss:0.15365\teval-mlogloss:0.29320\n",
      "[152]\ttrain-mlogloss:0.15305\teval-mlogloss:0.29344\n",
      "[153]\ttrain-mlogloss:0.15264\teval-mlogloss:0.29355\n",
      "[154]\ttrain-mlogloss:0.15205\teval-mlogloss:0.29389\n",
      "[155]\ttrain-mlogloss:0.15159\teval-mlogloss:0.29421\n",
      "[156]\ttrain-mlogloss:0.15105\teval-mlogloss:0.29468\n",
      "[157]\ttrain-mlogloss:0.15058\teval-mlogloss:0.29478\n",
      "[158]\ttrain-mlogloss:0.14993\teval-mlogloss:0.29495\n",
      "[159]\ttrain-mlogloss:0.14944\teval-mlogloss:0.29489\n",
      "[160]\ttrain-mlogloss:0.14896\teval-mlogloss:0.29479\n",
      "[161]\ttrain-mlogloss:0.14841\teval-mlogloss:0.29473\n",
      "[162]\ttrain-mlogloss:0.14776\teval-mlogloss:0.29488\n",
      "[163]\ttrain-mlogloss:0.14728\teval-mlogloss:0.29508\n",
      "[164]\ttrain-mlogloss:0.14676\teval-mlogloss:0.29502\n",
      "[165]\ttrain-mlogloss:0.14613\teval-mlogloss:0.29517\n",
      "[166]\ttrain-mlogloss:0.14567\teval-mlogloss:0.29550\n",
      "[167]\ttrain-mlogloss:0.14531\teval-mlogloss:0.29568\n",
      "[168]\ttrain-mlogloss:0.14485\teval-mlogloss:0.29583\n",
      "[169]\ttrain-mlogloss:0.14441\teval-mlogloss:0.29606\n",
      "[170]\ttrain-mlogloss:0.14383\teval-mlogloss:0.29598\n",
      "[171]\ttrain-mlogloss:0.14330\teval-mlogloss:0.29632\n",
      "[172]\ttrain-mlogloss:0.14264\teval-mlogloss:0.29656\n",
      "[173]\ttrain-mlogloss:0.14226\teval-mlogloss:0.29664\n",
      "[174]\ttrain-mlogloss:0.14178\teval-mlogloss:0.29692\n",
      "[175]\ttrain-mlogloss:0.14127\teval-mlogloss:0.29730\n",
      "[176]\ttrain-mlogloss:0.14074\teval-mlogloss:0.29737\n",
      "[177]\ttrain-mlogloss:0.14027\teval-mlogloss:0.29771\n",
      "[178]\ttrain-mlogloss:0.13975\teval-mlogloss:0.29799\n",
      "[179]\ttrain-mlogloss:0.13922\teval-mlogloss:0.29830\n",
      "[180]\ttrain-mlogloss:0.13880\teval-mlogloss:0.29862\n",
      "[181]\ttrain-mlogloss:0.13839\teval-mlogloss:0.29891\n",
      "[182]\ttrain-mlogloss:0.13797\teval-mlogloss:0.29894\n",
      "[183]\ttrain-mlogloss:0.13748\teval-mlogloss:0.29897\n",
      "[184]\ttrain-mlogloss:0.13709\teval-mlogloss:0.29904\n",
      "[185]\ttrain-mlogloss:0.13669\teval-mlogloss:0.29916\n",
      "[186]\ttrain-mlogloss:0.13624\teval-mlogloss:0.29924\n",
      "[187]\ttrain-mlogloss:0.13574\teval-mlogloss:0.29975\n",
      "[188]\ttrain-mlogloss:0.13533\teval-mlogloss:0.29985\n",
      "[189]\ttrain-mlogloss:0.13497\teval-mlogloss:0.29992\n",
      "[190]\ttrain-mlogloss:0.13452\teval-mlogloss:0.29976\n",
      "[191]\ttrain-mlogloss:0.13426\teval-mlogloss:0.29984\n",
      "[192]\ttrain-mlogloss:0.13380\teval-mlogloss:0.30009\n",
      "[193]\ttrain-mlogloss:0.13330\teval-mlogloss:0.30042\n",
      "[194]\ttrain-mlogloss:0.13287\teval-mlogloss:0.30051\n",
      "[195]\ttrain-mlogloss:0.13248\teval-mlogloss:0.30032\n",
      "[196]\ttrain-mlogloss:0.13204\teval-mlogloss:0.30045\n",
      "[197]\ttrain-mlogloss:0.13167\teval-mlogloss:0.30064\n",
      "[198]\ttrain-mlogloss:0.13134\teval-mlogloss:0.30100\n",
      "[199]\ttrain-mlogloss:0.13109\teval-mlogloss:0.30114\n",
      "[200]\ttrain-mlogloss:0.13076\teval-mlogloss:0.30136\n",
      "[201]\ttrain-mlogloss:0.13038\teval-mlogloss:0.30162\n",
      "[202]\ttrain-mlogloss:0.12996\teval-mlogloss:0.30186\n",
      "[203]\ttrain-mlogloss:0.12956\teval-mlogloss:0.30203\n",
      "[204]\ttrain-mlogloss:0.12926\teval-mlogloss:0.30221\n",
      "[205]\ttrain-mlogloss:0.12895\teval-mlogloss:0.30241\n",
      "[206]\ttrain-mlogloss:0.12849\teval-mlogloss:0.30250\n",
      "Stopping. Best iteration:\n",
      "[106]\ttrain-mlogloss:0.18411\teval-mlogloss:0.28640\n",
      "\n",
      "xgb now score is: [2.2977992902230473, 2.4689512671623377, 2.4576862342189996, 2.3780351165588947]\n",
      "[0]\ttrain-mlogloss:0.67123\teval-mlogloss:0.67057\n",
      "Multiple eval metrics have been passed: 'eval-mlogloss' will be used for early stopping.\n",
      "\n",
      "Will train until eval-mlogloss hasn't improved in 100 rounds.\n",
      "[1]\ttrain-mlogloss:0.65080\teval-mlogloss:0.64980\n",
      "[2]\ttrain-mlogloss:0.63147\teval-mlogloss:0.63011\n",
      "[3]\ttrain-mlogloss:0.61312\teval-mlogloss:0.61181\n",
      "[4]\ttrain-mlogloss:0.59579\teval-mlogloss:0.59462\n",
      "[5]\ttrain-mlogloss:0.57958\teval-mlogloss:0.57825\n",
      "[6]\ttrain-mlogloss:0.56383\teval-mlogloss:0.56225\n",
      "[7]\ttrain-mlogloss:0.54915\teval-mlogloss:0.54749\n",
      "[8]\ttrain-mlogloss:0.53522\teval-mlogloss:0.53309\n",
      "[9]\ttrain-mlogloss:0.52176\teval-mlogloss:0.51933\n",
      "[10]\ttrain-mlogloss:0.50905\teval-mlogloss:0.50647\n",
      "[11]\ttrain-mlogloss:0.49704\teval-mlogloss:0.49414\n",
      "[12]\ttrain-mlogloss:0.48558\teval-mlogloss:0.48246\n",
      "[13]\ttrain-mlogloss:0.47443\teval-mlogloss:0.47118\n",
      "[14]\ttrain-mlogloss:0.46383\teval-mlogloss:0.46039\n",
      "[15]\ttrain-mlogloss:0.45387\teval-mlogloss:0.45057\n",
      "[16]\ttrain-mlogloss:0.44400\teval-mlogloss:0.44053\n",
      "[17]\ttrain-mlogloss:0.43495\teval-mlogloss:0.43132\n",
      "[18]\ttrain-mlogloss:0.42608\teval-mlogloss:0.42214\n",
      "[19]\ttrain-mlogloss:0.41760\teval-mlogloss:0.41366\n",
      "[20]\ttrain-mlogloss:0.40966\teval-mlogloss:0.40541\n",
      "[21]\ttrain-mlogloss:0.40196\teval-mlogloss:0.39761\n",
      "[22]\ttrain-mlogloss:0.39441\teval-mlogloss:0.38988\n",
      "[23]\ttrain-mlogloss:0.38723\teval-mlogloss:0.38268\n",
      "[24]\ttrain-mlogloss:0.38061\teval-mlogloss:0.37619\n",
      "[25]\ttrain-mlogloss:0.37428\teval-mlogloss:0.36972\n",
      "[26]\ttrain-mlogloss:0.36812\teval-mlogloss:0.36385\n",
      "[27]\ttrain-mlogloss:0.36227\teval-mlogloss:0.35806\n",
      "[28]\ttrain-mlogloss:0.35653\teval-mlogloss:0.35230\n",
      "[29]\ttrain-mlogloss:0.35112\teval-mlogloss:0.34692\n",
      "[30]\ttrain-mlogloss:0.34577\teval-mlogloss:0.34166\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[31]\ttrain-mlogloss:0.34080\teval-mlogloss:0.33685\n",
      "[32]\ttrain-mlogloss:0.33602\teval-mlogloss:0.33217\n",
      "[33]\ttrain-mlogloss:0.33137\teval-mlogloss:0.32761\n",
      "[34]\ttrain-mlogloss:0.32675\teval-mlogloss:0.32305\n",
      "[35]\ttrain-mlogloss:0.32244\teval-mlogloss:0.31860\n",
      "[36]\ttrain-mlogloss:0.31834\teval-mlogloss:0.31478\n",
      "[37]\ttrain-mlogloss:0.31419\teval-mlogloss:0.31091\n",
      "[38]\ttrain-mlogloss:0.31043\teval-mlogloss:0.30721\n",
      "[39]\ttrain-mlogloss:0.30680\teval-mlogloss:0.30370\n",
      "[40]\ttrain-mlogloss:0.30331\teval-mlogloss:0.30013\n",
      "[41]\ttrain-mlogloss:0.29995\teval-mlogloss:0.29711\n",
      "[42]\ttrain-mlogloss:0.29645\teval-mlogloss:0.29405\n",
      "[43]\ttrain-mlogloss:0.29302\teval-mlogloss:0.29086\n",
      "[44]\ttrain-mlogloss:0.28989\teval-mlogloss:0.28810\n",
      "[45]\ttrain-mlogloss:0.28695\teval-mlogloss:0.28547\n",
      "[46]\ttrain-mlogloss:0.28398\teval-mlogloss:0.28273\n",
      "[47]\ttrain-mlogloss:0.28113\teval-mlogloss:0.27997\n",
      "[48]\ttrain-mlogloss:0.27858\teval-mlogloss:0.27749\n",
      "[49]\ttrain-mlogloss:0.27587\teval-mlogloss:0.27501\n",
      "[50]\ttrain-mlogloss:0.27334\teval-mlogloss:0.27297\n",
      "[51]\ttrain-mlogloss:0.27068\teval-mlogloss:0.27082\n",
      "[52]\ttrain-mlogloss:0.26831\teval-mlogloss:0.26895\n",
      "[53]\ttrain-mlogloss:0.26589\teval-mlogloss:0.26686\n",
      "[54]\ttrain-mlogloss:0.26377\teval-mlogloss:0.26479\n",
      "[55]\ttrain-mlogloss:0.26155\teval-mlogloss:0.26276\n",
      "[56]\ttrain-mlogloss:0.25932\teval-mlogloss:0.26098\n",
      "[57]\ttrain-mlogloss:0.25710\teval-mlogloss:0.25912\n",
      "[58]\ttrain-mlogloss:0.25483\teval-mlogloss:0.25734\n",
      "[59]\ttrain-mlogloss:0.25265\teval-mlogloss:0.25591\n",
      "[60]\ttrain-mlogloss:0.25083\teval-mlogloss:0.25456\n",
      "[61]\ttrain-mlogloss:0.24893\teval-mlogloss:0.25329\n",
      "[62]\ttrain-mlogloss:0.24732\teval-mlogloss:0.25176\n",
      "[63]\ttrain-mlogloss:0.24543\teval-mlogloss:0.25031\n",
      "[64]\ttrain-mlogloss:0.24370\teval-mlogloss:0.24918\n",
      "[65]\ttrain-mlogloss:0.24203\teval-mlogloss:0.24786\n",
      "[66]\ttrain-mlogloss:0.24036\teval-mlogloss:0.24672\n",
      "[67]\ttrain-mlogloss:0.23875\teval-mlogloss:0.24558\n",
      "[68]\ttrain-mlogloss:0.23719\teval-mlogloss:0.24439\n",
      "[69]\ttrain-mlogloss:0.23565\teval-mlogloss:0.24319\n",
      "[70]\ttrain-mlogloss:0.23408\teval-mlogloss:0.24211\n",
      "[71]\ttrain-mlogloss:0.23268\teval-mlogloss:0.24128\n",
      "[72]\ttrain-mlogloss:0.23131\teval-mlogloss:0.24036\n",
      "[73]\ttrain-mlogloss:0.22981\teval-mlogloss:0.23945\n",
      "[74]\ttrain-mlogloss:0.22845\teval-mlogloss:0.23867\n",
      "[75]\ttrain-mlogloss:0.22710\teval-mlogloss:0.23800\n",
      "[76]\ttrain-mlogloss:0.22569\teval-mlogloss:0.23729\n",
      "[77]\ttrain-mlogloss:0.22442\teval-mlogloss:0.23668\n",
      "[78]\ttrain-mlogloss:0.22284\teval-mlogloss:0.23602\n",
      "[79]\ttrain-mlogloss:0.22153\teval-mlogloss:0.23532\n",
      "[80]\ttrain-mlogloss:0.22030\teval-mlogloss:0.23483\n",
      "[81]\ttrain-mlogloss:0.21908\teval-mlogloss:0.23438\n",
      "[82]\ttrain-mlogloss:0.21780\teval-mlogloss:0.23397\n",
      "[83]\ttrain-mlogloss:0.21660\teval-mlogloss:0.23317\n",
      "[84]\ttrain-mlogloss:0.21544\teval-mlogloss:0.23278\n",
      "[85]\ttrain-mlogloss:0.21437\teval-mlogloss:0.23223\n",
      "[86]\ttrain-mlogloss:0.21328\teval-mlogloss:0.23167\n",
      "[87]\ttrain-mlogloss:0.21220\teval-mlogloss:0.23128\n",
      "[88]\ttrain-mlogloss:0.21112\teval-mlogloss:0.23056\n",
      "[89]\ttrain-mlogloss:0.21016\teval-mlogloss:0.23034\n",
      "[90]\ttrain-mlogloss:0.20914\teval-mlogloss:0.22997\n",
      "[91]\ttrain-mlogloss:0.20807\teval-mlogloss:0.22967\n",
      "[92]\ttrain-mlogloss:0.20688\teval-mlogloss:0.22946\n",
      "[93]\ttrain-mlogloss:0.20564\teval-mlogloss:0.22931\n",
      "[94]\ttrain-mlogloss:0.20480\teval-mlogloss:0.22878\n",
      "[95]\ttrain-mlogloss:0.20402\teval-mlogloss:0.22851\n",
      "[96]\ttrain-mlogloss:0.20307\teval-mlogloss:0.22824\n",
      "[97]\ttrain-mlogloss:0.20208\teval-mlogloss:0.22809\n",
      "[98]\ttrain-mlogloss:0.20108\teval-mlogloss:0.22761\n",
      "[99]\ttrain-mlogloss:0.20004\teval-mlogloss:0.22749\n",
      "[100]\ttrain-mlogloss:0.19915\teval-mlogloss:0.22704\n",
      "[101]\ttrain-mlogloss:0.19813\teval-mlogloss:0.22673\n",
      "[102]\ttrain-mlogloss:0.19715\teval-mlogloss:0.22670\n",
      "[103]\ttrain-mlogloss:0.19615\teval-mlogloss:0.22648\n",
      "[104]\ttrain-mlogloss:0.19529\teval-mlogloss:0.22646\n",
      "[105]\ttrain-mlogloss:0.19422\teval-mlogloss:0.22628\n",
      "[106]\ttrain-mlogloss:0.19328\teval-mlogloss:0.22619\n",
      "[107]\ttrain-mlogloss:0.19225\teval-mlogloss:0.22621\n",
      "[108]\ttrain-mlogloss:0.19154\teval-mlogloss:0.22612\n",
      "[109]\ttrain-mlogloss:0.19068\teval-mlogloss:0.22594\n",
      "[110]\ttrain-mlogloss:0.18964\teval-mlogloss:0.22574\n",
      "[111]\ttrain-mlogloss:0.18884\teval-mlogloss:0.22579\n",
      "[112]\ttrain-mlogloss:0.18801\teval-mlogloss:0.22588\n",
      "[113]\ttrain-mlogloss:0.18727\teval-mlogloss:0.22597\n",
      "[114]\ttrain-mlogloss:0.18641\teval-mlogloss:0.22600\n",
      "[115]\ttrain-mlogloss:0.18561\teval-mlogloss:0.22570\n",
      "[116]\ttrain-mlogloss:0.18488\teval-mlogloss:0.22557\n",
      "[117]\ttrain-mlogloss:0.18410\teval-mlogloss:0.22550\n",
      "[118]\ttrain-mlogloss:0.18342\teval-mlogloss:0.22557\n",
      "[119]\ttrain-mlogloss:0.18274\teval-mlogloss:0.22549\n",
      "[120]\ttrain-mlogloss:0.18206\teval-mlogloss:0.22552\n",
      "[121]\ttrain-mlogloss:0.18132\teval-mlogloss:0.22550\n",
      "[122]\ttrain-mlogloss:0.18056\teval-mlogloss:0.22554\n",
      "[123]\ttrain-mlogloss:0.17974\teval-mlogloss:0.22550\n",
      "[124]\ttrain-mlogloss:0.17889\teval-mlogloss:0.22564\n",
      "[125]\ttrain-mlogloss:0.17813\teval-mlogloss:0.22562\n",
      "[126]\ttrain-mlogloss:0.17750\teval-mlogloss:0.22583\n",
      "[127]\ttrain-mlogloss:0.17678\teval-mlogloss:0.22578\n",
      "[128]\ttrain-mlogloss:0.17610\teval-mlogloss:0.22595\n",
      "[129]\ttrain-mlogloss:0.17536\teval-mlogloss:0.22596\n",
      "[130]\ttrain-mlogloss:0.17471\teval-mlogloss:0.22609\n",
      "[131]\ttrain-mlogloss:0.17397\teval-mlogloss:0.22613\n",
      "[132]\ttrain-mlogloss:0.17316\teval-mlogloss:0.22626\n",
      "[133]\ttrain-mlogloss:0.17236\teval-mlogloss:0.22644\n",
      "[134]\ttrain-mlogloss:0.17179\teval-mlogloss:0.22670\n",
      "[135]\ttrain-mlogloss:0.17115\teval-mlogloss:0.22654\n",
      "[136]\ttrain-mlogloss:0.17048\teval-mlogloss:0.22681\n",
      "[137]\ttrain-mlogloss:0.16983\teval-mlogloss:0.22711\n",
      "[138]\ttrain-mlogloss:0.16911\teval-mlogloss:0.22703\n",
      "[139]\ttrain-mlogloss:0.16854\teval-mlogloss:0.22707\n",
      "[140]\ttrain-mlogloss:0.16795\teval-mlogloss:0.22735\n",
      "[141]\ttrain-mlogloss:0.16721\teval-mlogloss:0.22761\n",
      "[142]\ttrain-mlogloss:0.16662\teval-mlogloss:0.22746\n",
      "[143]\ttrain-mlogloss:0.16603\teval-mlogloss:0.22765\n",
      "[144]\ttrain-mlogloss:0.16542\teval-mlogloss:0.22745\n",
      "[145]\ttrain-mlogloss:0.16473\teval-mlogloss:0.22745\n",
      "[146]\ttrain-mlogloss:0.16410\teval-mlogloss:0.22722\n",
      "[147]\ttrain-mlogloss:0.16346\teval-mlogloss:0.22722\n",
      "[148]\ttrain-mlogloss:0.16292\teval-mlogloss:0.22696\n",
      "[149]\ttrain-mlogloss:0.16240\teval-mlogloss:0.22717\n",
      "[150]\ttrain-mlogloss:0.16164\teval-mlogloss:0.22752\n",
      "[151]\ttrain-mlogloss:0.16102\teval-mlogloss:0.22793\n",
      "[152]\ttrain-mlogloss:0.16041\teval-mlogloss:0.22798\n",
      "[153]\ttrain-mlogloss:0.15989\teval-mlogloss:0.22780\n",
      "[154]\ttrain-mlogloss:0.15926\teval-mlogloss:0.22788\n",
      "[155]\ttrain-mlogloss:0.15861\teval-mlogloss:0.22780\n",
      "[156]\ttrain-mlogloss:0.15795\teval-mlogloss:0.22806\n",
      "[157]\ttrain-mlogloss:0.15742\teval-mlogloss:0.22837\n",
      "[158]\ttrain-mlogloss:0.15685\teval-mlogloss:0.22834\n",
      "[159]\ttrain-mlogloss:0.15639\teval-mlogloss:0.22830\n",
      "[160]\ttrain-mlogloss:0.15583\teval-mlogloss:0.22827\n",
      "[161]\ttrain-mlogloss:0.15517\teval-mlogloss:0.22834\n",
      "[162]\ttrain-mlogloss:0.15470\teval-mlogloss:0.22860\n",
      "[163]\ttrain-mlogloss:0.15411\teval-mlogloss:0.22861\n",
      "[164]\ttrain-mlogloss:0.15369\teval-mlogloss:0.22860\n",
      "[165]\ttrain-mlogloss:0.15329\teval-mlogloss:0.22870\n",
      "[166]\ttrain-mlogloss:0.15281\teval-mlogloss:0.22866\n",
      "[167]\ttrain-mlogloss:0.15247\teval-mlogloss:0.22868\n",
      "[168]\ttrain-mlogloss:0.15198\teval-mlogloss:0.22884\n",
      "[169]\ttrain-mlogloss:0.15135\teval-mlogloss:0.22888\n",
      "[170]\ttrain-mlogloss:0.15092\teval-mlogloss:0.22877\n",
      "[171]\ttrain-mlogloss:0.15049\teval-mlogloss:0.22898\n",
      "[172]\ttrain-mlogloss:0.14993\teval-mlogloss:0.22918\n",
      "[173]\ttrain-mlogloss:0.14934\teval-mlogloss:0.22926\n",
      "[174]\ttrain-mlogloss:0.14883\teval-mlogloss:0.22919\n",
      "[175]\ttrain-mlogloss:0.14832\teval-mlogloss:0.22935\n",
      "[176]\ttrain-mlogloss:0.14783\teval-mlogloss:0.22946\n",
      "[177]\ttrain-mlogloss:0.14740\teval-mlogloss:0.22951\n",
      "[178]\ttrain-mlogloss:0.14695\teval-mlogloss:0.22979\n",
      "[179]\ttrain-mlogloss:0.14652\teval-mlogloss:0.22984\n",
      "[180]\ttrain-mlogloss:0.14599\teval-mlogloss:0.23004\n",
      "[181]\ttrain-mlogloss:0.14548\teval-mlogloss:0.23006\n",
      "[182]\ttrain-mlogloss:0.14506\teval-mlogloss:0.23006\n",
      "[183]\ttrain-mlogloss:0.14465\teval-mlogloss:0.23025\n",
      "[184]\ttrain-mlogloss:0.14419\teval-mlogloss:0.23035\n",
      "[185]\ttrain-mlogloss:0.14380\teval-mlogloss:0.23061\n",
      "[186]\ttrain-mlogloss:0.14336\teval-mlogloss:0.23067\n",
      "[187]\ttrain-mlogloss:0.14297\teval-mlogloss:0.23088\n",
      "[188]\ttrain-mlogloss:0.14251\teval-mlogloss:0.23093\n",
      "[189]\ttrain-mlogloss:0.14214\teval-mlogloss:0.23102\n",
      "[190]\ttrain-mlogloss:0.14183\teval-mlogloss:0.23100\n",
      "[191]\ttrain-mlogloss:0.14140\teval-mlogloss:0.23118\n",
      "[192]\ttrain-mlogloss:0.14097\teval-mlogloss:0.23133\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[193]\ttrain-mlogloss:0.14060\teval-mlogloss:0.23147\n",
      "[194]\ttrain-mlogloss:0.14012\teval-mlogloss:0.23172\n",
      "[195]\ttrain-mlogloss:0.13964\teval-mlogloss:0.23142\n",
      "[196]\ttrain-mlogloss:0.13928\teval-mlogloss:0.23162\n",
      "[197]\ttrain-mlogloss:0.13901\teval-mlogloss:0.23156\n",
      "[198]\ttrain-mlogloss:0.13867\teval-mlogloss:0.23157\n",
      "[199]\ttrain-mlogloss:0.13822\teval-mlogloss:0.23155\n",
      "[200]\ttrain-mlogloss:0.13786\teval-mlogloss:0.23172\n",
      "[201]\ttrain-mlogloss:0.13761\teval-mlogloss:0.23187\n",
      "[202]\ttrain-mlogloss:0.13725\teval-mlogloss:0.23198\n",
      "[203]\ttrain-mlogloss:0.13695\teval-mlogloss:0.23198\n",
      "[204]\ttrain-mlogloss:0.13661\teval-mlogloss:0.23211\n",
      "[205]\ttrain-mlogloss:0.13617\teval-mlogloss:0.23250\n",
      "[206]\ttrain-mlogloss:0.13572\teval-mlogloss:0.23250\n",
      "[207]\ttrain-mlogloss:0.13533\teval-mlogloss:0.23256\n",
      "[208]\ttrain-mlogloss:0.13505\teval-mlogloss:0.23276\n",
      "[209]\ttrain-mlogloss:0.13473\teval-mlogloss:0.23272\n",
      "[210]\ttrain-mlogloss:0.13426\teval-mlogloss:0.23278\n",
      "[211]\ttrain-mlogloss:0.13386\teval-mlogloss:0.23293\n",
      "[212]\ttrain-mlogloss:0.13351\teval-mlogloss:0.23316\n",
      "[213]\ttrain-mlogloss:0.13321\teval-mlogloss:0.23313\n",
      "[214]\ttrain-mlogloss:0.13287\teval-mlogloss:0.23304\n",
      "[215]\ttrain-mlogloss:0.13257\teval-mlogloss:0.23338\n",
      "[216]\ttrain-mlogloss:0.13232\teval-mlogloss:0.23337\n",
      "[217]\ttrain-mlogloss:0.13197\teval-mlogloss:0.23338\n",
      "[218]\ttrain-mlogloss:0.13163\teval-mlogloss:0.23336\n",
      "[219]\ttrain-mlogloss:0.13136\teval-mlogloss:0.23347\n",
      "Stopping. Best iteration:\n",
      "[119]\ttrain-mlogloss:0.18274\teval-mlogloss:0.22549\n",
      "\n",
      "xgb now score is: [2.2977992902230473, 2.4689512671623377, 2.4576862342189996, 2.3780351165588947, 2.4968769497517496]\n",
      "xgb_score_list: [2.2977992902230473, 2.4689512671623377, 2.4576862342189996, 2.3780351165588947, 2.4968769497517496]\n",
      "xgb_score_mean: 2.4198697715830058\n"
     ]
    }
   ],
   "source": [
    "clf_list = clf_list\n",
    "column_list = []\n",
    "train_data_list=[]\n",
    "test_data_list=[]\n",
    "for clf in clf_list:\n",
    "    train_data,test_data,clf_name=clf(x_train, y_train, x_valid, kf, label_split=None)\n",
    "    train_data_list.append(train_data)\n",
    "    test_data_list.append(test_data)\n",
    "train_stacking = np.concatenate(train_data_list, axis=1)\n",
    "test_stacking = np.concatenate(test_data_list, axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 原始特征和stacking特征合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 205,
   "metadata": {},
   "outputs": [],
   "source": [
    "# # 合并所有特征\n",
    "train = pd.DataFrame(np.concatenate([x_train, train_stacking], axis=1))\n",
    "test = np.concatenate([x_valid, test_stacking], axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 特征重命名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 206,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_train_all = pd.DataFrame(train)\n",
    "df_train_all.columns = features_columns + clf_list_col\n",
    "df_test_all = pd.DataFrame(test)\n",
    "df_test_all.columns = features_columns + clf_list_col"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 获取数据ID以及特征标签LABEL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_train_all['label'] = all_data_test['label']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 训练数据和测试数据保存"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_train_all.to_csv('train_all.csv',header=True,index=False)\n",
    "df_test_all.to_csv('test_all.csv',header=True,index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
